By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
version() |
---|
5.7.39 |
@sql |
---|
SELECT r,val, MAX(CASE WHEN Company = "Chicago's Best Construction" THEN totals ELSE NULL END) AS "Chicago's Best Construction",MAX(CASE WHEN Company = "Jones Construction" THEN totals ELSE NULL END) AS "Jones Construction" FROM (SELECT 1 as r,company, "TotalRevenue" val, TotalRevenue totals FROM comp_financials UNION ALL SELECT 2, company, "Overhead", Overhead FROM comp_financials UNION ALL SELECT 3, company, "TotalJobCosts", TotalJobCosts FROM comp_financials UNION ALL SELECT 4, company, "GrossProfit", GrossProfit FROM comp_financials) B GROUP BY r,val ORDER BY r ASC |
r | val | Chicago's Best Construction | Jones Construction |
---|---|---|---|
1 | TotalRevenue | 2098001 | 4509458 |
2 | Overhead | 363750 | 1067008 |
3 | TotalJobCosts | 1424420 | 2876568 |
4 | GrossProfit | 673581 | 1632890 |
r | val | Jones construction | Chicago's Best Construction |
---|---|---|---|
1 | TotalRevenue | 4509458 | 2098001 |
2 | Overhead | 1067008 | 363750 |
3 | TotalJobCosts | 2876568 | 1424420 |
4 | GrossProfit | 1632890 | 673581 |
r | company | val | totals |
---|---|---|---|
1 | Jones Construction | TotalRevenue | 4509458 |
1 | Chicago's Best Construction | TotalRevenue | 2098001 |
2 | Jones Construction | Overhead | 1067008 |
2 | Chicago's Best Construction | Overhead | 363750 |
3 | Jones Construction | TotalJobCosts | 2876568 |
3 | Chicago's Best Construction | TotalJobCosts | 1424420 |
4 | Jones Construction | GrossProfit | 1632890 |
4 | Chicago's Best Construction | GrossProfit | 673581 |