---
title: "Salary Report Generator - SQL Interview Query 5 | SQL Problem Level \"MEDIUM\""
url: https://daily.dev/posts/salary-report-generator---sql-interview-query-5-sql-problem-level-medium--g0gfxjcwz
source_url: https://www.youtube.com/watch?v=DKYg8JahHI0
type: video:youtube
source: "techTFQ"
published: 2026-05-31T07:43:12.624Z
updated: 2026-05-31T07:56:09.677Z
tags: ["sql", "postgresql", "microsoft-sql-server"]
reading_time: 30
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Salary Report Generator - SQL Interview Query 5 | SQL Problem Level "MEDIUM"

**[techTFQ](https://daily.dev/sources/techtfq)** · 30 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of a medium-difficulty SQL interview problem: generating a salary report from three input tables (salary, income, deduction). The solution covers populating an employee transaction table using CROSS JOIN and UNION, then transforming row-level data into columnar format. Two approaches are demonstrated: PostgreSQL's crosstab function (via the tablefunc extension) and Microsoft SQL Server's PIVOT operator. Key concepts include integer division pitfalls, the importance of ORDER BY in crosstab queries, and computing derived columns like gross salary, total deductions, and net pay.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=DKYg8JahHI0>

---

Tags: [#sql](https://daily.dev/tags/sql), [#postgresql](https://daily.dev/tags/postgresql), [#microsoft-sql-server](https://daily.dev/tags/microsoft-sql-server)

[View this post on daily.dev](https://daily.dev/posts/salary-report-generator---sql-interview-query-5-sql-problem-level-medium--g0gfxjcwz)
