
August 23rd, 2004, 12:28 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Need hep with simple query. New to Oracle
Hi All
I am new to Oracle. Please help with me with the following.
I have two tables master and detail say TableA and TableB
TableA is my master table which has customer_id(primary), customer_name fields in it.
Table b is my detail table, which has order_no(primary key) and customer_id (foreign key). So there are few rows for each customer in TableB with different oder numbers.
I want to display the customer name along with the total number of orders he has placed for a given period.
I am writing query like this.
select count(order.order_no) from customer left join order on customer.customer_id = order.customer_id and order.creation_date between '01-jun-04' and '07-jun-04' group by customer.customer_id;
This displays the total number of orders for each customer , even if there are no orders for a customer. Yes I want this.. But I want to add customer name or customer_id in the result. I modified the query to add order.customer_id but I am getting the error "ORA-00979: not a GROUP BY expression"
Can anybody give me the right query
Thanks in advance
vasu
|