From 6bb11daa70d3236a3a958965c5ee15ac0b06969c Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:05:11 +0530 Subject: [PATCH 01/20] Revising Aggregations - The Count Function.pgsql --- Revising Aggregations - The Count Function.pgsql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Revising Aggregations - The Count Function.pgsql diff --git a/Revising Aggregations - The Count Function.pgsql b/Revising Aggregations - The Count Function.pgsql new file mode 100644 index 0000000..9c98b17 --- /dev/null +++ b/Revising Aggregations - The Count Function.pgsql @@ -0,0 +1,3 @@ +select count(Population) +from CITY +where Population>100000; From 769de1401cae8363d659bf17665e18bca8188c1a Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:06:44 +0530 Subject: [PATCH 02/20] Average Population.pgsql --- Average Population.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Average Population.pgsql diff --git a/Average Population.pgsql b/Average Population.pgsql new file mode 100644 index 0000000..6c26722 --- /dev/null +++ b/Average Population.pgsql @@ -0,0 +1,2 @@ +select floor (avg(population)) +from city ; From ad66a38874df0e17c93046a536b1412ed93cc44c Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:07:54 +0530 Subject: [PATCH 03/20] Create Japanese Cities' Names.pgsql --- Japanese Cities' Names.pgsql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Japanese Cities' Names.pgsql diff --git a/Japanese Cities' Names.pgsql b/Japanese Cities' Names.pgsql new file mode 100644 index 0000000..460d53e --- /dev/null +++ b/Japanese Cities' Names.pgsql @@ -0,0 +1,10 @@ + +/* + Enter your query here and follow these instructions: + 1. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error. + 2. The AS keyword causes errors, so follow this convention: "Select t.Field From table1 t" instead of "select t.Field From table1 AS t" + 3. Type your code immediately after comment. Don't leave any blank line. +*/ +SELECT NAME +FROM CITY +WHERE COUNTRYCODE = 'JPN'; From f402913cdb23be6d250f24ca42e448206bd12b24 Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:08:50 +0530 Subject: [PATCH 04/20] Create Weather Observation Station 12.pgsql --- Weather Observation Station 12.pgsql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Weather Observation Station 12.pgsql diff --git a/Weather Observation Station 12.pgsql b/Weather Observation Station 12.pgsql new file mode 100644 index 0000000..dd52f29 --- /dev/null +++ b/Weather Observation Station 12.pgsql @@ -0,0 +1,6 @@ +/* +Enter your query here. +*/ +select distinct city +from station +where city regexp '^[^aeiou].*[^aeiou]$'; From 3020f983119f873d38f190518e9331cabb543056 Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:10:58 +0530 Subject: [PATCH 05/20] Rename Revising the Select Query I.txt to Revising the Select Query.pgsql --- ...ng the Select Query I.txt => Revising the Select Query.pgsql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Revising the Select Query I.txt => Revising the Select Query.pgsql (65%) diff --git a/Revising the Select Query I.txt b/Revising the Select Query.pgsql similarity index 65% rename from Revising the Select Query I.txt rename to Revising the Select Query.pgsql index 855bb06..2ec931f 100644 --- a/Revising the Select Query I.txt +++ b/Revising the Select Query.pgsql @@ -1,3 +1,3 @@ SELECT * FROM City WHERE CountryCode ='USA' -AND POPULATION>100000; \ No newline at end of file +AND POPULATION>100000; From 71e60c71c307e883987c71b01f46ce3b9f05e3e9 Mon Sep 17 00:00:00 2001 From: Sahastra Kishore <52572171+Sahastracookcoder1@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:11:33 +0530 Subject: [PATCH 06/20] Create Weather Observation Station 18.pgsql --- Weather Observation Station 18.pgsql | 1 + 1 file changed, 1 insertion(+) create mode 100644 Weather Observation Station 18.pgsql diff --git a/Weather Observation Station 18.pgsql b/Weather Observation Station 18.pgsql new file mode 100644 index 0000000..2ffd5e6 --- /dev/null +++ b/Weather Observation Station 18.pgsql @@ -0,0 +1 @@ +select round((max(lat_n)-min(lat_n))+(max(long_w)-min(long_w)),4) from station; From 46e0075b093701710852023ab71eb049763bc7a6 Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:11:45 +0530 Subject: [PATCH 07/20] Rename Top Earners.txt to Top Earners.pgsql --- Top Earners.txt => Top Earners.pgsql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Top Earners.txt => Top Earners.pgsql (100%) diff --git a/Top Earners.txt b/Top Earners.pgsql similarity index 100% rename from Top Earners.txt rename to Top Earners.pgsql From 5a91716d893880b6b190363b99a7c0de648a401c Mon Sep 17 00:00:00 2001 From: Vikas Kumar <12.vikaskumar99@gmail.com> Date: Thu, 7 Oct 2021 00:13:09 +0530 Subject: [PATCH 08/20] Rename Revising the Select Query II.txt to Revising the Select Query II.pgsql --- ...he Select Query II.txt => Revising the Select Query II.pgsql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Revising the Select Query II.txt => Revising the Select Query II.pgsql (65%) diff --git a/Revising the Select Query II.txt b/Revising the Select Query II.pgsql similarity index 65% rename from Revising the Select Query II.txt rename to Revising the Select Query II.pgsql index 7f4e661..f187c3a 100644 --- a/Revising the Select Query II.txt +++ b/Revising the Select Query II.pgsql @@ -1,3 +1,3 @@ SELECT NAME FROM CITY WHERE COUNTRYCODE='USA' -AND POPULATION>=120000; \ No newline at end of file +AND POPULATION>=120000; From aa1b3391c3f886aef4c95a9cf4438bd8f6c42e61 Mon Sep 17 00:00:00 2001 From: Sahastra Kishore <52572171+Sahastracookcoder1@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:14:04 +0530 Subject: [PATCH 09/20] Create Higher Than 75 Marks.pgsql --- Higher Than 75 Marks.pgsql | 1 + 1 file changed, 1 insertion(+) create mode 100644 Higher Than 75 Marks.pgsql diff --git a/Higher Than 75 Marks.pgsql b/Higher Than 75 Marks.pgsql new file mode 100644 index 0000000..719e442 --- /dev/null +++ b/Higher Than 75 Marks.pgsql @@ -0,0 +1 @@ +SELECT NAME FROM STUDENTS WHERE MARKS>75 ORDER BY RIGHT(NAME,3),ID ASC; From aaf263d985ad6abc60b4dc68a813c7cf2e86fac7 Mon Sep 17 00:00:00 2001 From: Sahastra Kishore <52572171+Sahastracookcoder1@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:15:37 +0530 Subject: [PATCH 10/20] Create Type of Triangle.pgsql --- Type of Triangle.pgsql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Type of Triangle.pgsql diff --git a/Type of Triangle.pgsql b/Type of Triangle.pgsql new file mode 100644 index 0000000..529b39a --- /dev/null +++ b/Type of Triangle.pgsql @@ -0,0 +1,11 @@ +SELECT CASE +WHEN A+B>C AND A+C>B AND B+C>A THEN +CASE +WHEN A=B AND A=C THEN 'Equilateral' +WHEN A=B OR B=C OR A=C THEN 'Isosceles' +ELSE 'Scalene' +END + +ELSE 'Not A Triangle' +END +FROM TRIANGLES; From a8618dc12ee99fedfa091e340bd27cdece05cd07 Mon Sep 17 00:00:00 2001 From: Sahastra Kishore <52572171+Sahastracookcoder1@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:18:05 +0530 Subject: [PATCH 11/20] Create African Cities.pgsql --- African Cities.pgsql | 1 + 1 file changed, 1 insertion(+) create mode 100644 African Cities.pgsql diff --git a/African Cities.pgsql b/African Cities.pgsql new file mode 100644 index 0000000..1dcebae --- /dev/null +++ b/African Cities.pgsql @@ -0,0 +1 @@ +SELECT city.NAME FROM CITY INNER JOIN country on CITY.COUNTRYCODE=COUNTRY.CODE WHERE COUNTRY.CONTINENT='Africa'; From ec5cb05c64bb82c99996e9dd802ba8e4fc5d9b32 Mon Sep 17 00:00:00 2001 From: Harsh Tyagi <48311361+HarshTyagi007@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:17:52 +0530 Subject: [PATCH 12/20] Create Revising Aggregations.pgsql --- Revising Aggregations.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Revising Aggregations.pgsql diff --git a/Revising Aggregations.pgsql b/Revising Aggregations.pgsql new file mode 100644 index 0000000..5e7389c --- /dev/null +++ b/Revising Aggregations.pgsql @@ -0,0 +1,2 @@ +--https://www.hackerrank.com/challenges/revising-aggregations-sum/problem +select sum(population) from city where district="California" ; From 51923c34007518704af62fb8f5b98644ed4fe4bc Mon Sep 17 00:00:00 2001 From: Harsh Tyagi <48311361+HarshTyagi007@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:21:27 +0530 Subject: [PATCH 13/20] Create The PADS.pgsql --- The PADS.pgsql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 The PADS.pgsql diff --git a/The PADS.pgsql b/The PADS.pgsql new file mode 100644 index 0000000..bf533a7 --- /dev/null +++ b/The PADS.pgsql @@ -0,0 +1,3 @@ +--https://www.hackerrank.com/challenges/the-pads/problem +select concat(name,'(',left(OCCUPATION,1),')') from OCCUPATIONS order by name; +select concat('There are a total of ',count(OCCUPATION),' ',lower(OCCUPATION),'s.') from OCCUPATIONS group by OCCUPATION order by count(OCCUPATION); From 8ecfb69d26e06feb487cdc2816740d6918f8402c Mon Sep 17 00:00:00 2001 From: Harsh Tyagi <48311361+HarshTyagi007@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:26:28 +0530 Subject: [PATCH 14/20] Create Weather Observation Station 5.pgsql --- Weather Observation Station 5.pgsql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Weather Observation Station 5.pgsql diff --git a/Weather Observation Station 5.pgsql b/Weather Observation Station 5.pgsql new file mode 100644 index 0000000..c7c95d0 --- /dev/null +++ b/Weather Observation Station 5.pgsql @@ -0,0 +1,5 @@ +--https://www.hackerrank.com/challenges/weather-observation-station-5/problem +select city , length(city) from station +order by length(city) ,city limit 1; +select city , length(city) from station +order by length(city) desc, city limit 1; From 495c71628fb4a5e17329224c7ab1a43cc7c95e2f Mon Sep 17 00:00:00 2001 From: Harsh Tyagi <48311361+HarshTyagi007@users.noreply.github.com> Date: Thu, 7 Oct 2021 13:00:19 +0530 Subject: [PATCH 15/20] Create PopulationCensus.pgsql (#12) --- PopulationCensus.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 PopulationCensus.pgsql diff --git a/PopulationCensus.pgsql b/PopulationCensus.pgsql new file mode 100644 index 0000000..73bb41f --- /dev/null +++ b/PopulationCensus.pgsql @@ -0,0 +1,2 @@ +--https://www.hackerrank.com/challenges/asian-population/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign +select sum(c.population) from city as c,country as ct where C.CountryCode=Ct.Code and CONTINENT = 'Asia'; From fb1565b1d3da5804a5adaef83b4b189aa0e36405 Mon Sep 17 00:00:00 2001 From: Ankit Raj <44525721+ankit039@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:28:12 +0530 Subject: [PATCH 16/20] Create binary-tree-node.pgsql --- binary-tree-node.pgsql | 1 + 1 file changed, 1 insertion(+) create mode 100644 binary-tree-node.pgsql diff --git a/binary-tree-node.pgsql b/binary-tree-node.pgsql new file mode 100644 index 0000000..3922729 --- /dev/null +++ b/binary-tree-node.pgsql @@ -0,0 +1 @@ +SELECT N, IF(P IS NULL,’Root’,IF((SELECT COUNT(*) FROM BST WHERE P=B.N)>0,’Inner’,’Leaf’)) FROM BST AS B ORDER BY N; From 7650239feb160f5b623fd431f2a86473ab9c71c8 Mon Sep 17 00:00:00 2001 From: sahastrakishore123 <44016054+sahastrakishore123@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:23:05 +0530 Subject: [PATCH 17/20] Create select_by_id.pgsql --- select_by_id.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 select_by_id.pgsql diff --git a/select_by_id.pgsql b/select_by_id.pgsql new file mode 100644 index 0000000..7128803 --- /dev/null +++ b/select_by_id.pgsql @@ -0,0 +1,2 @@ +SELECT * FROM CITY +WHERE ID="1661"; From d64ce7d5938cd87429288324dd9d3a4f75b72ac8 Mon Sep 17 00:00:00 2001 From: sahastrakishore123 <44016054+sahastrakishore123@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:25:03 +0530 Subject: [PATCH 18/20] Create Population_density.pgsql --- Population_density.pgsql | 1 + 1 file changed, 1 insertion(+) create mode 100644 Population_density.pgsql diff --git a/Population_density.pgsql b/Population_density.pgsql new file mode 100644 index 0000000..6c64eb8 --- /dev/null +++ b/Population_density.pgsql @@ -0,0 +1 @@ +SELECT MAX(POPULATION)- MIN(POPULATION) FROM CITY; From e0991dd25e8b61eba353ba1fa39ae907b569e6b1 Mon Sep 17 00:00:00 2001 From: sahastrakishore123 <44016054+sahastrakishore123@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:27:49 +0530 Subject: [PATCH 19/20] Added Draw_the_triangle.pgsql --- draw_the_triangle1.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 draw_the_triangle1.pgsql diff --git a/draw_the_triangle1.pgsql b/draw_the_triangle1.pgsql new file mode 100644 index 0000000..bd88718 --- /dev/null +++ b/draw_the_triangle1.pgsql @@ -0,0 +1,2 @@ +set @num= 21; +select repeat('* ', @num := @num -1) from information_schema.tables; From 939df22e9266c42eb201ebb3a3fd5f8d6dbd4cb0 Mon Sep 17 00:00:00 2001 From: sahastrakishore123 <44016054+sahastrakishore123@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:29:03 +0530 Subject: [PATCH 20/20] Create draw_the_triangle2.pgsql --- draw_the_triangle2.pgsql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 draw_the_triangle2.pgsql diff --git a/draw_the_triangle2.pgsql b/draw_the_triangle2.pgsql new file mode 100644 index 0000000..fcdcdb8 --- /dev/null +++ b/draw_the_triangle2.pgsql @@ -0,0 +1,2 @@ +set @num=0; +select repeat('* ', @num := @num+1) from information_schema.tables LIMIT 20;