Advertisement
Pandaaaa906

Untitled

Oct 12th, 2022
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. SELECT
  2. y, m, sales_code, sales_name,
  3. [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27],[28],[29],[30],[31]
  4. FROM (
  5. SELECT y, m, d, sales_code, sales_name, so_sum
  6. FROM cim_summary
  7. ) AS src
  8. PIVOT
  9. (
  10. sum(so_sum)
  11. for d in (
  12. [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27],[28],[29],[30],[31]
  13. )
  14. ) as pvt
  15. ORDER BY sales_code, y, m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement