By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,469 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,469 IT Pros & Developers. It's quick & easy.

query to produce a table with 7 columns based on the values in a two column table

P: 1
I need a query that will 'Select' 6 columns named MN, S1, S2, S3, S4, S5 where the value in MN is derived from column A's value where column B's value is -1 and the value in columns S1-S5 are derived from column A's value where column B's value is the value of MN. Every row should have the 7 columns. Those that do not produce a value should be 'NULL'. You can assume the order in the table is exactly as the order of the columns in the output.

This is an example of a table
A B
10 -1
50 10
51 10
52 10
11 -1
60 11
61 11
62 11
63 11
12 -1
70 12
71 12
72 12
73 12
74 12

This is how the output should look
MN S1 S2 S3 S4 S5
10 50 51 52
11 60 61 62 63
12 70 71 72 73 74
4 Weeks Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.