Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jdrella17
Starting Member
3 Posts |
Posted - 2012-09-28 : 21:05:32
|
I am fairly new to SQL Server and I am having some trouble pairing common fields as pairs. Here is the example of the problem: List Part_Num, "Description", and Class for each pair of parts that are in the same class. (EX...AT94 and FD21 are a pair because they are in the same class-HW). Here is a partial table for parts.PART_NUM DESCRIPTION CLASSAT94 Iron HW BV06 Home Gym SG CD52 Microwave Oven AP DL71 Cordless Drill HW DR93 Gas Range APDW11 Washer APFD21 Stand Mixer HW KL62 Dryer AP KT03 Dishwasher AP KV29 Treadmill SGAny advice or help would be greatly appreciated. A brief explanation would be fantastic. Thank you all in advance. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-28 : 23:41:57
|
how do you want the result to looks like ? KH[spoiler]Time is always against us[/spoiler] |
|
|
jdrella17
Starting Member
3 Posts |
Posted - 2012-09-29 : 00:08:27
|
You know, that is a great question. I guess I should have asked that because thinking about it, I am not even sure. I originally was thinking on using GROUP BY, but then that would list all items in class HW and not pairs. The more I read this question, the more confused I get. If you have any suggestions, feel free to let me know. Honestly, I am not even understanding what it is asking. If you are wondering, yes, this is for an ungraded challenge assignment. It is just starting to consume me so now I need to know the output |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-29 : 00:16:11
|
probably justORDER BY CLASS ? KH[spoiler]Time is always against us[/spoiler] |
|
|
jdrella17
Starting Member
3 Posts |
Posted - 2012-09-29 : 00:55:19
|
I figured it out and I did group it by class. For anyone that is curious, here it is.select a.Part_Num, a."description", a.class, b.part_num, b."description", b.classfrom PART a, part bwhere a.CLASS = b.CLASS and a.PART_NUM < b.PART_NUMorder by a.class, b.class ;Thanks for the help. I know it wasn't much, but you did attempt to help me out. Very much appreciated. |
|
|
|
|
|
|
|