Monday, March 19, 2012

Help needed!

Hello guys,
I'm new to the forum and to MS SQL 2K.
I'm trying to a merge similar rows in a table into a single row and put them in a new table.

Example:-
This is my input table
TableA
ID A B C
--------
1 jk kl bj
2 sd we op
3 io po kl
1 ui gh ew
2 kl re op
1 qw kj nn

My output table should look like this
TableB
ID A1 B1 C1 A2 B2 C2 A3 B3 C3
----------------
1 jk kl bj ui gh ew qw kj nn
2 sd we op kl re op
3 io po kl

Please help me on how to create my output.
Thanks in advance,

Sid.You want help violating the rules of normalization? Should I buy you a carton of cigarettes while I'm at it? Neither activity is healthy.

Seriously, if you must do this it is important to know whether the number of records for an ID is fixed or not. If it can be any number then you are not going to be able to define the columns on your output table ahead of time and you are left with a messy dynamic query task. If there is a limit on the number of records per ID then your problem is merely a moderately difficult cross-tab query.|||normalization or not
this is a good exercise to displace data
kinda like playing scales before you actually play a song on an instrument

i will be working on this tonight|||I'll check this query today ...|||giving up

I don't understand to purpose of this query|||i now have a headache|||There's not much point in pursuing this without further clarification from coolhandsid, so save the Tylenol.|||I've got

Table1
ID | A | B | C
1 | 2 | 3 | 4
2 | 9 | 4 | 5
3 | 22| 53 94

I want this result

Table1
ID X Y Z
1 | 81 | April | NULL
Y | 12 | Dog | Sheep
12.3 | Cherry | Spain | 3|||I've got broccolli and I want lobster. I can't make one out of the other either.|||Remeber the MASH episode (when they used to be good) when they made the spam lamb for the turkish troops?|||Originally posted by blindman
You want help violating the rules of normalization? Should I buy you a carton of cigarettes while I'm at it? Neither activity is healthy.

I would not want you doing the first ... but you can certainly buy that carton of cigs for me ...|||Thanks for all your help :),

I figured it out , it can be down by a DTS package or a cross-tab query.

Sid.

Originally posted by Karolyn
I've got

Table1
ID | A | B | C
1 | 2 | 3 | 4
2 | 9 | 4 | 5
3 | 22| 53 94

I want this result

Table1
ID X Y Z
1 | 81 | April | NULL
Y | 12 | Dog | Sheep
12.3 | Cherry | Spain | 3

No comments:

Post a Comment