For a data table I would like to create the following table:

store department gender workers_count
A Light Male 10
A Light Female 5
A Plumbing Male 20
A Plumbing Female 0
2 35
B Food Male 12
B Food Female 12
1 24

For each store department and gender, I would like to count the number of workers and for each store to count the number of departments and workers

  • Have you got sample data Sep 27 at 16:15

1 Answer 1


This is a translation of your description into SQL:

... GROUP BY GROUPING SETS ((store, department, gender), (store))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.