var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: how to select 2 from every blah
This is probably really obvious but I am trying to craft a query which will return 2 rows for every set of criteria.
select name, department from users
If I just add 'limit 2', then I get 2 total rows when what I really want is 2 users from every department (doesn't really matter which).
For departments with < 2 users, I would ideally like to have at least 1.
Any help is appreciated.
Once again, what version are you running?
SELECT department, name
SELECT department, name,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY name) AS rn
WHERE sub.rn < 3
Thanks! That did the trick.