Guideline.....

  • Hello

    Does anyone know how I can script in T-SQL a result similar to the attached excel template?

    I just need a sample, not an actual script to put me in the right direction, so it can be:

    select date, a,b,c from table

    where a > 500

    group by date

    order by date asc

  • b_boy (9/19/2008)


    Hello

    Does anyone know how I can script in T-SQL a result similar to the attached excel template?

    I just need a sample, not an actual script to put me in the right direction, so it can be:

    select date, a,b,c from table

    where a > 500

    group by date

    order by date asc

    A case will be useful in such scenario. Consider the following example:

    select count(orderid), sum(case when shipmentaddress <> billaddress then 1 else 0 end), sum(case when deleverydate = orderdate +1 then 1 else 0 end)

    and so on.

  • arjun.tewari (9/19/2008)



    sum(case when deleverydate = orderdate +1 then 1 else 0 end)

    and so on.

    This part of the query returned o as dates, or maybe there is something I dont uderstand, i have copied the query used for each column, in the attached spreadsheet, maybe that will help.

  • If you want better help, please practice the methods and recommendations found in the link in my signature below. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply