7 kyu
Products per Supplier without GROUP BY
209bornForThis
Description:
You are working with a database that contains information about various products supplied by different suppliers. The database has a table named products
, which has the following schema:
id
: (integer) - Primary keysupplier_id
: (integer) – The unique identifier for each supplier.product_name
: (varchar) – The name of the product.quantity
: (integer) – The quantity of the product in stock.
Write a SQL query to find the total count of rows for each supplier, representing the total number of products (regardless of product name) for each supplier. Your query must not use the GROUP BY clause. But results should be exactly the same as in the query with Group By:
select supplier_id, count(id) as total_products
from products
group by supplier_id
order by supplier_id desc;
Your query must return exactly two columns:
supplier_id
: The unique identifier for the supplier.total_products
: The total number of products for that supplier.
Result set should be ordered by supplier_id
in descending order.
GLHF!
SQL
Databases
Restricted
Similar Kata:
Stats:
Created | Aug 4, 2023 |
Published | Aug 4, 2023 |
Warriors Trained | 415 |
Total Skips | 59 |
Total Code Submissions | 619 |
Total Times Completed | 209 |
SQL Completions | 209 |
Total Stars | 7 |
% of votes with a positive feedback rating | 92% of 32 |
Total "Very Satisfied" Votes | 27 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |