Subject | this works, but is it the best way? |
---|---|
Author | Dixon Epperson |
Post date | 2005-02-28T18:04:52Z |
We have a table of invoices, what I am looking for is where an
invoice is assigned to two different customer numbers. The separate
customer numbers might point to the same customer, but by having a
double entry here, they could get a double rebate.
Right now the table is real small, but it will probably get huge.
I will limit the scope of the query to a date range, and I do have an
index on SD_GTLINENO, SD_INVOICE, and SD_GTID and also on the invoice
date field. (SD_GTLINENO IS a unique identifier.)
Is there a better way to make sure you don't have one invoice pointing
to separate customer ID?
SELECT s.SD_GTLINENO, s.SD_INVOICE, s.SD_GTID, s1.SD_GTID FROM
SALESDATA s, SALESDATA s1
WHERE s.SD_GTID != s1.SD_GTID
AND s1.SD_INVOICE=s.SD_INVOICE
I do appreciate any help,
E. D. Epperson Jr.
invoice is assigned to two different customer numbers. The separate
customer numbers might point to the same customer, but by having a
double entry here, they could get a double rebate.
Right now the table is real small, but it will probably get huge.
I will limit the scope of the query to a date range, and I do have an
index on SD_GTLINENO, SD_INVOICE, and SD_GTID and also on the invoice
date field. (SD_GTLINENO IS a unique identifier.)
Is there a better way to make sure you don't have one invoice pointing
to separate customer ID?
SELECT s.SD_GTLINENO, s.SD_INVOICE, s.SD_GTID, s1.SD_GTID FROM
SALESDATA s, SALESDATA s1
WHERE s.SD_GTID != s1.SD_GTID
AND s1.SD_INVOICE=s.SD_INVOICE
I do appreciate any help,
E. D. Epperson Jr.