SQL Server Performance

query using variable

Discussion in 'Getting Started' started by RVG, Feb 20, 2010.

  1. RVG Member

    hi,
    Here is my table data.
    ShiftID Name StartTime EndTime ModifiedDate
    ------- -------------------------------------------------- ----------------------- ----------------------- -----------------------
    1 Day 1900-01-01 07:00:00.000 1900-01-01 15:00:00.000 1998-06-01 00:00:00.000
    2 Evening 1900-01-01 15:00:00.000 1900-01-01 23:00:00.000 1998-06-01 00:00:00.000
    3 Night 1900-01-01 23:00:00.000 1900-01-01 07:00:00.000 1998-06-01 00:00:00.000

    ColumnName
    I want to o/p of the query in the form of evening,night,day
    ratherthan
    Columnname
    evening
    night
    day
    how to get the query in the above format using variable
    Thanks,
    Ravi
  2. Adriaan New Member

    Why are you asking specifically about using a variable?
    This can be resolved with a cross-tab query. Check out the "PIVOT" syntax in Books Online, or use Excel or Access to do a TRANSFORM (which will be a lot easier to set up than PIVOT).

Share This Page