Sql 2000 turning rows into columns

  • I would like a denormalised table or view which had a column for each distinct date returned along with inward,intDepLevel,vchrdesc, intCount in the query below any ideas?

     

    Insert into tbl_PDS_Period_Report

        ( dtmDate , intWard , vchrDesc,intDeplevel,intcount )

         select    a.dtmDate,

         a.intWard,

         b.vchrDesc,

         a.intDepLevel,

         count(intBedNo)

        from tbl_PDS_Dep_Level a,

                      tbl_PDS_Ward b

        where a.intWard = b.intWard_ID 

        group by dtmDate,intWard,intDepLevel,b.vchrDesc 

  • No easy way to do this in SQL that I know of. You can return these in rows and then compute the number of distincts. Create a temp table using that many columns and then loop through and update them into the temp table.

  • Thank-you Steve . Kind of you to reply I suppose there is not always a quick solution. Kind regards Denise

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

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