Hi all.
I'm having trouble with a query and was hoping someone could help me.
I have two tables that JOIN on t_number and usi_system_ref. There can be many entries in table2 to the one entry in table1. The usi_category is basically a type of entry. I am trying to do a query that will give me all of the entries grouped by usi_system_ref (or t_number) where the usi_category only equals 3289 for all of the entries, ie it has only ever had this one type of entry put into it.
The query below does not work, but to me looks like it should. Any bright ideas?
Thanks
Samaritan
Code:
SELECT table1.t_reference, table2.usi_category, table1.t_cancelled
FROM table1 ,table2
WHERE table1.t_number IN
(SELECT usi_system_ref
FROM table2
WHERE usi_category = 3289
AND usi_category NOT IN (3291, 3292, 3293, 14072, 14074, 23536, 23537, 28831, 40589, 40590, 40592)
GROUP BY usi_system_ref)
and t_number = usi_system_ref
ORDER BY usi_system_ref, usi_category desc