Subquery [message #1671] |
Tue, 21 May 2002 11:10 |
ckr
Messages: 13 Registered: May 2002
|
Junior Member |
|
|
hai,
I have two tables Orders and Customers which are related by Cust_id.here i just want to know the total no of orders placed by each customer.
I used the query
select cust_name,cust_state,
(select count(*)
from orders
where orders.cust_id=customers.cust_id) as orders
from customers
order by cust_name;
the result is 'missing expression ' at subquery.
is there anything wrong with this query
please help me
|
|
|
|
|
Re: Subquery [message #1742 is a reply to message #1671] |
Sat, 25 May 2002 08:05 |
N. Rammohan
Messages: 5 Registered: May 2002
|
Junior Member |
|
|
you can use this simple querry
select cust_name,cust_state, count(*)
from orders o,customers c
where o.cust_id=c.cust_id
group by cust_name,cust_stat
order by cust_name;
|
|
|