MySQL Forums
Forum List  »  Spanish

SQL Query
Posted by: Alvaro Garcia Solano
Date: October 22, 2017 01:51PM

Hi forum, I have a table with store info (idstore, storename) and another table with orders (idorder, idstore, etc..)

I need to know the number of orders for each store placed yesterday. The format of the output will be:

STORE_NAME NUM_ORDERS
Store1 5
Store2 10


The seudocode is the following:

X = SELECT STORE_ID, STORE_NAME FROM STORE

And for each X:

SELECT COUNT (*)
FROM ORDERS
WHERE TIMEPLACED > CURRENT TIMESTAMP-1DAY AND STORE_ID = X;

Can you help me please, I have tried to explain the best as possible.

Thanks beforehand.

Options: ReplyQuote


Subject
Views
Written By
Posted
SQL Query
480
October 22, 2017 01:51PM
178
October 22, 2017 05:19PM
185
October 23, 2017 07:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.