From 663a7fde60ce6455ead5cb0247fca6a750a45776 Mon Sep 17 00:00:00 2001 From: tanusreeg Date: Wed, 6 Feb 2019 18:17:10 +0530 Subject: [PATCH] Update 01-sql-queries.sql I have added 2 more complex queries to the list. As in the project, it is said to use 'CASE'. --- sql/01-sql-queries.sql | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sql/01-sql-queries.sql b/sql/01-sql-queries.sql index 9988350..c435d88 100644 --- a/sql/01-sql-queries.sql +++ b/sql/01-sql-queries.sql @@ -198,7 +198,29 @@ INSERT INTO marvels VALUES(12, "Rogue", 4, "Good", "Female", 1.73, 54.43, "USA", select name, min(popularity) from marvels; select name, max(popularity) from marvels; - +/* insert a new row*/ +INTO marvels VALUES(13, "R1", 82, "Bad", "Female", 1.73, 54.43, "USA", 7, 7, 7, 7, 7, 7); + +/* On the basis of popularity add new column named 'public_review' */ +select name, popularity, +case +when popularity<10 then 'highly popular' +when popularity>=10 and popularity<=80 then 'moderately popular' +when popularity > 80 and popularity<=90 then 'not so well known' +else 'Hmm..hv to google' +end as 'public_choice' +from marvels order by popularity; + +/* display how many no. of characters are 'highly popular','moderately popular' etc. and order this list by descending order*/ +select count(*) as no_of_char, +case +when popularity<10 then 'highly popular' +when popularity>=10 and popularity<=80 then 'moderately popular' +when popularity > 80 and popularity<=90 then 'not so well known' +else 'Hmm..hv to google' +end as 'public_choice' +from marvels group by public_choice order by no_of_char DESC; +