I have two tables, say Customers and Invoices and I want a query to show some customer information along with the # of invoices they have...
From what I understand a group by fields list must also be included in the GROUP BY ...
So this works fine:
SELECT c.cust_no, COUNT(*)
FROM "customers" c, "invoices" i
WHERE c.cust_no=i.cust_no
GROUP BY c.cust_no
And
SELECT c.cust_no, c.cust_name, COUNT(*)
does not
So how can I also have fields like cust_name, cust_city etc returned along with the # of invoices?
Thanks
Paul
Paul Wesson, Programmer/Analyst
From what I understand a group by fields list must also be included in the GROUP BY ...
So this works fine:
SELECT c.cust_no, COUNT(*)
FROM "customers" c, "invoices" i
WHERE c.cust_no=i.cust_no
GROUP BY c.cust_no
And
SELECT c.cust_no, c.cust_name, COUNT(*)
does not
So how can I also have fields like cust_name, cust_city etc returned along with the # of invoices?
Thanks
Paul
Paul Wesson, Programmer/Analyst