Occupations in SQL | HackerRank Programming Solutions | HackerRank SQL Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language SQL. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Occupations in SQL-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To SQL

SQL stands for Structured Query Language. SQL is used to create, remove, alter the database and database objects in a database management system and to store, retrieve, update the data in a database. SQL is a standard language for creating, accessing, manipulating database management system. SQL works for all modern relational database management systems, like SQL Server, Oracle, MySQL, etc.

  • It is a standard language for Relational Database System. It enables a user to create, read, update and delete relational databases and tables.
  • All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their standard database language.
  • SQL allows users to query the database in a number of ways, using English-like statements.

Link for the ProblemOccupations SQL – Hacker Rank Solution

Occupations SQL – Hacker Rank Solution

Problem:

Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.

Input Format

The Employee table containing employee data for a company is described as follows:

Occupations

where employee_id is an employee’s ID number, name is their name, months is the total number of months they’ve been working for the company, and salary is their monthly salary.

Sample Input

Occupations

Sample Output

Angela
Bonnie
Frank
Joe
Kimberly
Lisa
Michael
Patrick
Rose
Todd
Occupations SQL – Hacker Rank Solution
set @d=0, @p=0, @s=0, @a=0;

select min(Doctor), min(Professor), min(Singer), min(Actor)
from(
  select case 
            when Occupation='Doctor' then (@d:=@d+1)
            when Occupation='Professor' then (@p:=@p+1)
            when Occupation='Singer' then (@s:=@s+1)
            when Occupation='Actor' then (@a:=@a+1) 
            end as Row,
        case when Occupation='Doctor' then Name end as Doctor,
        case when Occupation='Professor' then Name end as Professor,
        case when Occupation='Singer' then Name end as Singer,
        case when Occupation='Actor' then Name end as Actor
  from OCCUPATIONS
  order by Name
) as temp
group by Row;

33 thoughts on “Occupations in SQL | HackerRank Programming Solutions | HackerRank SQL Solutions”

  1. We absolutely love your blog and find a lot of your post’s to be precisely what I’m looking for. Does one offer guest writers to write content to suit your needs? I wouldn’t mind producing a post or elaborating on many of the subjects you write with regards to here. Again, awesome web site!

    Reply
  2. You actually make it seem so easy along with your presentation but I find this topic to be actually something that I think I might never understand. It sort of feels too complex and extremely extensive for me. I’m looking ahead in your next submit, I’ll attempt to get the grasp of it!

    Reply
  3. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your site? My blog site is in the exact same niche as yours and my users would genuinely benefit from some of the information you provide here. Please let me know if this ok with you. Thanks!

    Reply
  4. Wow! This can be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Basically Fantastic. I’m also an expert in this topic so I can understand your hard work.

    Reply
  5. Aw, this was a really nice post. In thought I want to put in writing like this moreover – taking time and precise effort to make an excellent article… however what can I say… I procrastinate alot and certainly not appear to get one thing done.

    Reply
  6. Pingback: big gaming

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker🙏.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock