I am in desperate need for help with a query that has been taking too long to finish.
I have a specific set of data that is being grouped, but then I need to group it down to another level. The primary the columns to pay attention to are the OFFICEID, ID, and OFFICEREQ. I would like to return the first X (being the value shown in the OFFICEREQ field) users in each office. This list could easily grow to add more offices so it needs to be flexible and use the OFFICEREQ field to know how many will be selected.
I would very much like to keep this in one query to keep from getting to messy.
Does anyone have any solutions or simple queries I could try?
This is what the data looks like now.
OfficeID ID OfficeReq UserName Flag
8 89 3 XXXXX 1
8 245 3 XXXXX 1
8 319 3 XXXXX 1
8 257 3 XXXXX 1
8 88 3 XXXXX 1
8 306 3 XXXXX 1
8 254 3 XXXXX 1
8 271 3 XXXXX 1
8 248 3 XXXXX 1
9 179 5 XXXXX 1
9 173 5 XXXXX 1
9 62 5 XXXXX 1
9 115 5 XXXXX 1
9 64 5 XXXXX 1
9 134 5 XXXXX 1
9 60 5 XXXXX 1
9 73 5 XXXXX 1
9 74 5 XXXXX 1
9 75 5 XXXXX 1
9 162 5 XXXXX 1
9 71 5 XXXXX 1
9 148 5 XXXXX 1
9 142 5 XXXXX 1
9 176 5 XXXXX 1
The output would look exactly like this.
OfficeID ID OfficeReq Name Flag
8 89 3 XXXXX 1
8 245 3 XXXXX 1
8 319 3 XXXXX 1
9 179 5 XXXXX 1
9 173 5 XXXXX 1
9 62 5 XXXXX 1
9 115 5 XXXXX 1
9 64 5 XXXXX 1
Thank you very much in advance.
-Andrew
I have a specific set of data that is being grouped, but then I need to group it down to another level. The primary the columns to pay attention to are the OFFICEID, ID, and OFFICEREQ. I would like to return the first X (being the value shown in the OFFICEREQ field) users in each office. This list could easily grow to add more offices so it needs to be flexible and use the OFFICEREQ field to know how many will be selected.
I would very much like to keep this in one query to keep from getting to messy.
Does anyone have any solutions or simple queries I could try?
This is what the data looks like now.
OfficeID ID OfficeReq UserName Flag
8 89 3 XXXXX 1
8 245 3 XXXXX 1
8 319 3 XXXXX 1
8 257 3 XXXXX 1
8 88 3 XXXXX 1
8 306 3 XXXXX 1
8 254 3 XXXXX 1
8 271 3 XXXXX 1
8 248 3 XXXXX 1
9 179 5 XXXXX 1
9 173 5 XXXXX 1
9 62 5 XXXXX 1
9 115 5 XXXXX 1
9 64 5 XXXXX 1
9 134 5 XXXXX 1
9 60 5 XXXXX 1
9 73 5 XXXXX 1
9 74 5 XXXXX 1
9 75 5 XXXXX 1
9 162 5 XXXXX 1
9 71 5 XXXXX 1
9 148 5 XXXXX 1
9 142 5 XXXXX 1
9 176 5 XXXXX 1
The output would look exactly like this.
OfficeID ID OfficeReq Name Flag
8 89 3 XXXXX 1
8 245 3 XXXXX 1
8 319 3 XXXXX 1
9 179 5 XXXXX 1
9 173 5 XXXXX 1
9 62 5 XXXXX 1
9 115 5 XXXXX 1
9 64 5 XXXXX 1
Thank you very much in advance.
-Andrew