Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL SELECT

$
0
0

I am trying to select which clients invoices are sent to their invoice client (an alternate client who pays the bill) and whic are sent to the client himself. The client table has a client_number and an invoice_client_number.The invoice itself has a client number but it can be either invoice_client number or client number. THe only link to client from invoice is the client number. I thought that this would work...

SELECT iv.invoice_id,iv.client_number FROM t_invoice iv
join t_client c
on iv.client_number = c.invoice_client_number
and iv.client_number <> c.client_number
and c.invoice_client_number <> c.client_number
However, if a client has an invoice client,  that invoice client is also a client - in order to be an invoice client you must already be a client. So, the invoice client number can on one hand equal the invoice_client number yet it can also = the client number of a different client. Can this be resolved?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>