SQL Server Performance

Comple Query

Discussion in 'SQL Server 2005 General Developer Questions' started by danny123, Jun 16, 2009.

  1. danny123 New Member

    Hi there,
    I have a table which have following fields.
    strMonth -- Month Name
    strDate -- Date
    strDay -- Day
    Occupancy -- Numberic value
    STG - Numaric value.
    so for each month there are 30 or 31 entries for each day.
    Now i want result for say January month in which the dates become the columns (so there will be 31 columns) and there will be only 2 rows (first one displaying the value for Occupancy and second showing for STG)
    01/01/2009 01/02/2009 01/03/2009......................01/31/2009
    Occupancy 12 3 17 .......................... 21
    STG 4.5 2.0 5.1 0.3
    Is it possible and if possible how can i do this?
    Thanks alot in advance!
  2. Adriaan New Member

    This is known as a cross-tab query. Plenty of information available here and in Books Online.

Share This Page