I\'m having a problem with SQL. Can someone help? Here\'s what I have to do: Thi
ID: 3545432 • Letter: I
Question
I'm having a problem with SQL. Can someone help? Here's what I have to do:
This is the question as posed to me. Using the tables in my database, I'm supposed to write an SQL query showing.....
"...The store name, address, city, state, zip, and quantity of books sold in that store for each store. Place the list in descending order by the quantity of books sold..."
Ok. Got it. Here's what I have so far:
SELECT stores.stor_name, stores.stor_address, stores.city, stores.state, stores.zip, sales.qty
FROM sales INNER JOIN
stores ON sales.stor_id = stores.stor_id
ORDER BY sales.qty DESC
BUT, here's the problem: I'm NOT supposed to use INNER JOIN.
How do I write the above out WITHOUT using INNER JOIN?????
Explanation / Answer
if you dont want to user the word inner join and has to keep the same concept of inner join then the answer is
SELECT stores.stor_name, stores.stor_address, stores.city, stores.state, stores.zip, sales.qty
FROM sales ,
stores
where sales.stor_id = stores.stor_id
ORDER BY sales.qty DESC
or if you want to remove the inner join concept and has to get the same result then
SELECT stores.stor_name, stores.stor_address, stores.city, stores.state, stores.zip,
(select qty from stores where sales.stor_id = stores.stor_id) as qty
FROM sales
ORDER BY qty DESC
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.