SQL Query returns 'no rows selected'

Hi all,

I am very new to SQL programming, so I hope I am in the right place to get some help.

I have two tables of Data: A table full of Customer Data such as their Customer ID and their First name.

I also have a table full of order details: a

When I run the following Query:
SELECT Customer.ID, CUS_FNAME, COUNT(Orders.ID) AS NUMORDS, SUM(ORD_QUANTITY) AS NUMPRODS FROM Orders JOIN Customer ON Orders.ID = Customer.ID GROUP BY Customer.ID, CUS_FNAME ORDER BY CUS_FNAME;

I get the output 'no rows selected', meaning that the query is not working.

I am trying to show a table with the Customer ID which is the same as the Orders ID, along with the number of orders and the number of products (ORD_QUANTITY) in each order.

Any help is greatly appreciated. Thank you!

I cant see Customer.ID in your orders table.
How do you know if an order is mapped to a customer?

I have seen this in many systems - someone puts an ID column in the Order table and an ID column in the Customer table, but these are not the same ID.

The ID in the Order table is the OrderID and the ID in the Customer table is the CustomerID and both are generated when a new row is inserted in the table.

It is confusing for anyone...

What you need to do is identify the column in the Orders table that ties to the Customer table - often in these systems it will be something like CustomerID with a foreign key constraint and join on that column.

2 Likes