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 |
|
Mits
Starting Member
48 Posts |
Posted - 2007-03-10 : 09:38:19
|
| Hello everyoneI have 2 tables as followsInvoicedata ----------------------InvoicePayment[Invoice No]----------------------[Invoice No][Customer Id]---------------------[Amount Paid]I want to get all the records from Invoice data based on Customer Id and if the same [Invoice no] exists in InvoicePayment then it should return [Amount Paid] otherwise 0.0.I know its not very complicated but, I just cant think straight today.Any help would be niceMitesh |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-03-10 : 10:02:01
|
something like this?select id.[Invoice No] id.[Customer Id] ,coalesce(ip.[Amount Paid], 0.0)from InvoiceData idleft join InvoicePayment ip on ip.[Invoice No] = id.[Invoice No] EDIT: your life would be easier if you didn't put spaces in object/column names... www.elsasoft.org |
 |
|
|
Mits
Starting Member
48 Posts |
Posted - 2007-03-10 : 10:38:11
|
| hi jezemineyour solution is spot on. Thanks a lot.Mitesh |
 |
|
|
|
|
|