Introduction

    PRQL

    SQL

    1. SELECT
    2. title,
    3. country,
    4. salary + COALESCE(tax, 0) + benefits_cost AS _expr_1,
    5. salary + COALESCE(tax, 0) AS _expr_2
    6. FROM
    7. employees
    8. WHERE
    9. start_date > DATE '2021-01-01'
    10. ),
    11. SELECT
    12. country,
    13. AVG(_expr_2) AS _expr_0,
    14. SUM(_expr_1) AS sum_gross_cost
    15. FROM
    16. table_3 AS table_2
    17. WHERE
    18. _expr_1 > 0
    19. GROUP BY
    20. title,
    21. country
    22. )
    23. country,
    24. _expr_0,
    25. sum_gross_cost,
    26. CONCAT(title, '_', country) AS id,
    27. LEFT(country, 2) AS country_code
    28. FROM
    29. table_1 AS table_0
    30. WHERE
    31. sum_gross_cost > 100000
    32. ORDER BY
    33. sum_gross_cost,
    34. country DESC
    35. 20