MySQL Forums
Forum List  »  Newbie

ANIDATED SELECT
Posted by: Alvaro Garcia Solano
Date: October 22, 2017 01:55PM

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
Written By
Posted
ANIDATED SELECT
October 22, 2017 01:55PM
October 22, 2017 02:12PM
October 23, 2017 05:53AM
October 23, 2017 05:56AM
October 23, 2017 09:47AM
October 23, 2017 10:34AM
October 23, 2017 11:14AM
October 23, 2017 12:48PM
October 24, 2017 01:52AM
October 24, 2017 08:26AM


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.