Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GROUP BY Problems

Status
Not open for further replies.

pwesson

Programmer
Apr 10, 2000
95
0
0
CA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top