Occupations Pivot— HackerRank Advanced SQL

Amber Ivanna Trujillo
2 min readOct 19, 2020

Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively.

Note: Print NULL when there are no more names corresponding to an occupation. This is critical in interviews.

Input Format

The OCCUPATIONS table is described as follows:

--

--

Amber Ivanna Trujillo

I am Executive Data Science Manager. Interested in Deep Learning, LLM, Startup, AI-Influencer, Technical stuff, Interviews and much more!!!