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 |
|
jryannel
Starting Member
13 Posts |
Posted - 2003-12-30 : 20:26:37
|
| I have created a temporary table to join a lot of invoices together. However I have companies in multiple times because they have multiple invoices. Can I combine these records into a single record?? I have no idea how to write a query like this.I'm thinking like thisproduct invoice title orderidwidget 1 test 6widget 2 test 6combine intoproduct invoice1 invoice2 title orderidwidget 1 2 test 6 Thanks, Jeff |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2003-12-30 : 20:57:28
|
| [code]select product, min(invoice) invoice1, max(invoice) invoice2, title,orderidfrom prodgroup by product, title,orderid[/code] |
 |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-12-31 : 01:33:25
|
Jeff, what happens when you have more than two invoices? Would you add a column for every invoice number? Perhaps you want to show those invoice numbers as a comma-separated list. Take a look at this article for more information: http://www.sqlteam.com/item.asp?ItemID=2368OS |
 |
|
|
jryannel
Starting Member
13 Posts |
Posted - 2003-12-31 : 09:03:17
|
| ehorn, how do i account for 3 or more invoices? It seems like your query works for up to 2..Of course my example only had 2 in it, but I have some companies listed 3 or more times.Thanks |
 |
|
|
|
|
|