Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 6 of 6 total |
Top n rows per group |
Thu, Sep 13 2012 9:56 PM | Permanent Link |
ClockOn | how do you get the top 5 rows per group?
I basically have a list of employees with 2 different site numbers and and i want the top x number of employees for each site, i just cant figure this one out, in this list ive shown top 2... NAME ID SITENO Bob 100 001 Fred 4 002 Jack 41 002 Jill 11 001 Sam 23 001 Sarah 24 002 Tina 21 002 NAME ID SITENO Bob 100 001 Jill 11 001 Fred 4 002 Jack 41 002 |
Sun, Sep 16 2012 5:36 PM | Permanent Link |
Fernando Dias Team Elevate | ClockOn
You can do it with a temporary table and a script: SELECT * INTO TmpTable FROM EmpTable WHERE SiteNo = '001' ORDER BY Name TOP 5 ; INSERT INTO TmpTable SELECT * FROM EmpTable WHERE SiteNo = '002' ORDER BY Name TOP 5 ; SELECT * FROM TmpTable ; -- Fernando Dias [Team Elevate] |
Sun, Sep 16 2012 7:50 PM | Permanent Link |
ClockOn | Hi Fernando
thanks for the reply but i was hoping for something a bit more generic as in most instances I do not know the SiteNo. I was thinking of trying to get a running count by location of how many shifts there are and removing anything > 50 but Ive had no luck getting that running. |
Sun, Sep 16 2012 8:27 PM | Permanent Link |
ClockOn | I meant employees not shifts, lol...
|
Mon, Sep 17 2012 4:16 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | ClockOn
I think John Hay has posted a solution to this sort of problem. I can't remember which post it was but try searching for his name in these newsgroups. Roy Lambert [Team Elevate] |
Mon, Sep 17 2012 7:39 PM | Permanent Link |
ClockOn |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |