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 |
|
callawayx14
Yak Posting Veteran
73 Posts |
Posted - 2008-12-17 : 13:11:08
|
| Hello! I could really use some help with this one. My table looks like thistblTestCODE | TYPE | OLD | NEW | REQUEST_ID1 | Outbound | NULL | NULL | 1234562 | Inbound | ABC123 | MNB876 | NULL3 | Recreat | NULL | NULL | 123456I'm trying to display the result of my query like this. There will only be three records (at most) for each Request_ID.OLD | NEW | REQUEST_IDABC123 | MNB876 | 123456Thanks for any help |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-12-17 : 13:24:49
|
| can you specify your business rule a little more? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-17 : 13:32:36
|
| [code]SELECT MAX(OLD),MAX(NEW),REQUEST_IDFROM TableGROUP BY REQUEST_ID[/code] |
 |
|
|
callawayx14
Yak Posting Veteran
73 Posts |
Posted - 2008-12-17 : 13:36:48
|
| Yes, Thank you. Each Request_ID can only have three records identified by the Code field (1-3). the row with Code '1' will always contain the Request ID. The row with Code '2' will always contain the NEW 'ID' . The row with Code '3' doesn;t always exist. I have no use for the row with Code '3'I displayed the data in the table incorrectly the first tiem the OLD column is the one field that each record will have in common. I've displayed the correct version of the table belowCODE | TYPE | OLD_ID | NEW_ID | REQUEST_ID1 | Outbound | ABC123 | NULL | 1234562 | Inbound | ABC123 | MNB876 | NULL3 | Recreat | ABC123 | NULL | 123456OLD_ID | NEW_ID | REQUEST_IDABC123 | MNB876 | 123456 |
 |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-12-17 : 14:36:20
|
| [code]select max(OLD_ID),max(NEW_ID),max(request_ID) from Requestgroup by old_ID[/code] |
 |
|
|
callawayx14
Yak Posting Veteran
73 Posts |
Posted - 2008-12-17 : 16:51:34
|
| Thank you very much for tyour help!! |
 |
|
|
|
|
|