nerdalert1
Programmer
Hello all. I am running into an issue with a query I have. I have a query that takes 2 seconds to run it flies and returns a result set. There are 2 fields in the result set that I need to say "WHERE Field1 = Field2". However, it is totally hanging the query up and it runs forever. How can I handle this? I tried it in the WHERE CLAUSE AND A HAVING Clause. If I take the WHERE Clause or same with if I use HAVING clause the query returns 900 records in 2 seconds flat. For example,
SELECT CUSTOMER, DEPARTMENT, DEPARTMENT1, CUSTNAME,
SUM(T1 + T2) AS TA
SUM(T3 + T4) AS TB
FROM CUSTOMER
WHERE DEPARTMENT = DEPARTMENT1
GROUP BY CUSTOMER, DEPARTMENT, DEPARTMENT1, CUSTNAME
SELECT CUSTOMER, DEPARTMENT, DEPARTMENT1, CUSTNAME,
SUM(T1 + T2) AS TA
SUM(T3 + T4) AS TB
FROM CUSTOMER
WHERE DEPARTMENT = DEPARTMENT1
GROUP BY CUSTOMER, DEPARTMENT, DEPARTMENT1, CUSTNAME