Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- y, m, sales_code, sales_name,
- [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]
- FROM (
- SELECT y, m, d, sales_code, sales_name, so_sum
- FROM cim_summary
- ) AS src
- PIVOT
- (
- sum(so_sum)
- for d in (
- [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]
- )
- ) as pvt
- ORDER BY sales_code, y, m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement