├── LICENSE
├── README.md
├── country-codes.sql
├── merit-rewards.sql
├── profitable-stocks.sql
├── student-advisor.sql
└── student-analysis.sql
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Azhar Khan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Hackerrank SQL (Basic) Skills Certification Test Solution
2 |
3 | 
4 |
5 | I have taken HackerRank [test](https://www.hackerrank.com/skills-verification/sql_basic) on __3rd June 2022__.
6 | Certificate can be viewed [here](https://www.hackerrank.com/certificates/b8d32dd8308f)
7 |
8 | 2 Questions are asked, as of now 2 questions will be asked from these questions, provided the solution also:
9 | ## Programs / Questions
10 | - [Student Analysis](student-analysis.sql)
11 | - [Country Codes](country-codes.sql)
12 | - [Student Advisor](student-advisor.sql)
13 | - [Profitable Stocks](profitable-stocks.sql)
14 | - [Merit Rewards](merit-rewards.sql)
15 |
16 | ## Follow me
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | ## New Questions?
31 | If any new questions comes other than these, make sure to create PR/Issue.
32 |
33 | Will be adding SQL Advanced Questions soon in separate repo.
34 |
--------------------------------------------------------------------------------
/country-codes.sql:
--------------------------------------------------------------------------------
1 | SELECT a.customer_id,a.name,concat("+",b.country_code,a.phone_number)
2 | FROM customers as a
3 | LEFT join country_codes as b
4 | ON a.country=b.country
5 | ORDER BY a.customer_id;
--------------------------------------------------------------------------------
/merit-rewards.sql:
--------------------------------------------------------------------------------
1 | SELECT ei.employee_ID, ei.name
2 | FROM employee_information ei
3 | JOIN last_quarter_bonus b ON b.employee_ID = ei.employee_ID
4 | WHERE ei.division LIKE 'HR'
5 | AND b.bonus >= 5000;
--------------------------------------------------------------------------------
/profitable-stocks.sql:
--------------------------------------------------------------------------------
1 | SELECT a.stock_code
2 | FROM price_today a
3 | INNER JOIN price_tomorrow b
4 | ON a.stock_code = b.stock_code
5 | WHERE b.price>a.price
6 | ORDER BY stock_code asc;
--------------------------------------------------------------------------------
/student-advisor.sql:
--------------------------------------------------------------------------------
1 | SELECT roll_number,name
2 | FROM student_information a
3 | INNER JOIN faculty_information b
4 | ON a.advisor = b.employee_ID
5 | WHERE (b.gender = 'M' and b.salary>15000) or (b.gender = 'F' and b.salary>20000);
--------------------------------------------------------------------------------
/student-analysis.sql:
--------------------------------------------------------------------------------
1 | SELECT a.roll_number,a.name
2 | FROM student_information a
3 | INNER JOIN examination_marks b
4 | ON a.roll_number = b.roll_number
5 | GROUP BY b.roll_number
6 | HAVING SUM(b.subject_one + b.subject_two + b.subject_three) < 100;
--------------------------------------------------------------------------------