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 |
|
BRKWA
Starting Member
1 Post |
Posted - 2005-10-31 : 12:19:54
|
| I'm sure that this is a fairly easy statement but it exceeds my ability in SQL. What I am trying to do is double pull from one table. I am trying to build an aging report for my accounts payable dept. The table has some of the worst organization i've ever seen. I need to pull all records from the table with voucher type "V", and then pull all records with voucher type "C" or "X" but have them take the date of the records with voucher type "V" that share the same invoice #. Does this make any sense? I thought I knew how to do this but i've only managed to give myself a headache every time i come back to this point. Any help would be greatly appreciated. |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
|
|
mriverol
Starting Member
10 Posts |
Posted - 2005-11-01 : 08:23:02
|
| Hi, if i am understanding your issue correctly the following should workTest Table format and datavoucher invoice dtV 1 2005-01-01 00:00:00V 2 2005-01-09 00:00:00V 3 2005-01-15 00:00:00V 4 2005-01-19 00:00:00C 1 C 2 C 3 C 4 X 1 X 2 X 3 X 4 Query:update not_vset dt = v.dtfrom tbl vinner join tbl not_v on v.invoice = not_v.invoice and v.voucher = 'v' and not_v.voucher in ('c', 'x') Martin. |
 |
|
|
|
|
|