Getting good at SQL for interviews can feel like a puzzle. You know the basics, but putting them together in a way that impresses people is another thing entirely. Luckily, there are great tools out ...
MAX(CASE WHEN OCCUPATION = 'Doctor' THEN NAME END) AS DOCTOR, MAX(CASE WHEN OCCUPATION = 'Professor' THEN NAME END) AS PROFESSOR, MAX(CASE WHEN OCCUPATION = 'Singer' THEN NAME END) AS SINGER, MAX(CASE ...
1. Assign a row number to each name within its occupation using ROW_NUMBER(), ordered alphabetically. 2. Group names with the same row number together. 3. Pivot the Occupation values into separate ...