April 3, 2007 at 6:19 am
I have 2 tables like table-1 and table-2. I want to represent data like table-3. Is there any query which can retrive data from SQL Server2000 in my desired format? | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
Table -1 | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
Table-2 | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
Table-3, Desired Report |
April 3, 2007 at 8:22 am
First, please don't use so much whitespace in posts.
second, what you want is a cross tab. If this is for a report, it's much better to do this in the client/reporting engine.
IF not, you need to know how many columns you need. If you do, then
select a.id, a.name. a.address. b.quantity 'wrox', c.quantity 'oreilly'
from Table1 a
left outer join table2 b
on a.id = b.id
and b.products = 'wrox'
left outer join table2 c
on a.id = b.id
and b.products = 'oreilly'
April 3, 2007 at 11:04 pm
Dear Steve Jones,
Thanks for your answer.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply