May 6, 2005 at 4:41 am
Hello,
I have a query that currently returns
Code | Name | Project A | Grade | Hrs | Day |
5 | Jones, Mary | Project A | Grade 5 | 4 | dy |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy2 |
5 | Jones, Mary | Project A | Grade 5 | 4 | dy2 |
5 | Jones, Mary | Project A | Grade 5 | 4 | dy3 |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy3 |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy4 |
5 | Jones, Mary | Project A | Grade 5 | 4 | dy4 |
5 | Jones, Mary | Project A | Grade 5 | 0 | dy5 |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy5 |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy6 |
5 | Jones, Mary | Project A | Grade 5 | 0 | dy6 |
5 | Jones, Mary | Project A | Grade 5 | 0 | dy7 |
5 | Jones, Mary | Holiday | Grade 5 | 0 | dy7 |
however I need to modify it to return;
Code | Name | Grade | Project | dy | dy2 | dy3 | dy4 | dy5 | dy6 | dy7 |
5 | Jones, Mary | Grade 5 | Project A | 4 | 4 | 4 | 4 | 0 | 0 | 0 |
5 | Jones, Mary | Grade 6 | Holiday | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Someone told me that this is easy to do by just passing the results of the first query into a second query that can format it. However I'm not having any luck finding a resources to help me write this query.
Does anyone know if it is possible to accomplish just by using another query? and if any resorces to help me
thanks
May 6, 2005 at 4:56 am
Am I right, that you don't know in advance how many dy_ columns there will be?
If so, and given you don't want to do this at the client, have a look here:
http://www.windowsitpro.com/SQLServer/Article/ArticleID/15608/15608.html
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply