Simple Pivot in TSQL (SQL Server 2000)

read original post: Pivot in mssql2000

select 
   t.myid as furnisher,
   t1.myprice as price1_year,
   t2.myprice price2_year from 
(select distinct myid from mytable) t
join (select myid,myprice,rownum = (select count(*) from mytable t2 where t2.myid = t1.myid and t2.id <= t1.id) from mytable t1) t1 on
   t.myid = t1.myid and t1.rownum = 1
join (select myid, myprice, rownum = (select count(*) from mytable t2 where t2.myid = t1.myid and t2.id <= t1.id) from mytable t1) t2 on
   t.myid = t2.myid and t2.rownum = 2
order by 1
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Simple Pivot in TSQL (SQL Server 2000)

  1. Unknown says:

    To the global wow gold the cheapest wow power leveling under the cheapest single-site! -114271959019073

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s