SQL query with SELECT COUNT() in SELECT - subquery example

Would you please provide working example how to use SQL SELECT with COUNT() in SELECT query ?
14 May 2021 at 05:56 PM
0pnshow more
StorStor
Hi,

The subquery with "SELECT in SELECT" should look for example like this:

SELECT item_name FROM items AS i WHERE i.available_pcs = (SELECT COUNT(*) FROM reserved_items AS r WHERE i.item_id = r.item_id );
20 May 2021 at 11:29 AM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us