Forum Replies Created

Viewing 15 posts - 2,131 through 2,145 (of 4,087 total)

  • RE: compare two columns

    Assuming that column1 cannot be null, then this will give the same results and should be slightly faster.

    CASE

    WHEN column2 > column1

    THEN column2

    ELSE column1 END AS Result

    You have three...

  • RE: SP_EXECUTESQL query problem

    paul.biltcliffe 32759 (12/2/2016)


    Data Types:

    a.client = nvarchar(25), not null

    a.status = nvarchar(1), not null

    a.attribute_id = nvarchar(4), not null

    On an unrelated note, why are you using nvarchar(1) for your status instead of nchar(1)?...

  • RE: How would you track an insert to a detail table in your main table

    Phil Parkin (12/2/2016)


    Just having a mind warp on how to insert into the address table and get that unique int value and put it into the correct master row for...

  • RE: effective use of subquery with a where condition

    JALLY (12/2/2016)


    Your solution above will create a conflict between columns that rely on the the sub queries for their source of data and the multi part identifier 'inv.active' will not...

  • RE: effective use of subquery with a where condition

    You can't have a WHERE clause in the middle of your JOIN clause. Just move your WHERE clause after ALL of the JOIN clauses.

    ...

  • RE: can this be done in another way

    Something seems off here. You're worried about a new student status affecting the sort order, but that's impossible, because the student status defines the partition. You say that...

  • RE: Select continual date ranges from a list that overlaps

    Here is the updated code:

    ;

    WITH unique_dates AS (

    SELECT DISTINCT p.Price, d.dt, d.is_start

    FROM #prices p

    CROSS APPLY (VALUES(p.date_from, 1), (DATEADD(DAY, 1, p.date_to), 0)) d(dt, is_start)

    )

    , packed_dates AS (

    SELECT ud.price, ud.dt, ud.is_start,

    CASE

    WHEN LEAD(ud.dt,...

  • RE: OUTPUT

    UPDATE does allow you to use a named table as long as it's not the one being updated. If you use the name of the table that's being updated,...

  • RE: How to drop temp table created by somebody else?

    You can't. Temp tables are only visible to the session that created them.

    Drew

  • RE: Coalesce and Case

    dsmith402 (11/29/2016)


    Ok, that certainly makes sense. But how would this expression be re-written in order for it to work?

    It depends on what you are trying to solve, which is why...

  • RE: Coalesce and Case

    You have both a CASE expression and a COALESCE. For each of those, the possible values must be of compatible data types.

    ,coalesce(case WHEN FSI.FID IN ('1800','1810')

    and FSI.StepCompletion is not...

  • RE: Select continual date ranges from a list that overlaps

    wjh_uk (11/28/2016)


    Thank you so much for code, it is a lot faster but it has some issues that I am struggling to figure out.

    With the following data the faster version...

  • RE: Generate Running MAT from Quarter

    You say you want running totals, but your expected results look like they are the first step in getting your expected running totals. If that is the case, there...

  • RE: Merge Dates

    This is a variation of the packing intervals problem. Since you have no gaps and no overlaps you can treat it as a gaps and islands problem where the...

  • RE: t-sql 2012 update statment

    Your text contains a single quote that hasn't been properly escaped. You need to use two single quotes in your text to get one single quote, so child's should...

Viewing 15 posts - 2,131 through 2,145 (of 4,087 total)