Microsoft
Software
Hardware
Network
Question : SQL - For Each statement?
StoreID Score Date Area
002884 83 2008-06-19 00:00:00.000 4002756
002884 50 2008-04-22 00:00:00.000 4002756
002884 70 2007-12-20 00:00:00.000 4002756
002884 76 2007-06-20 00:00:00.000 4002756
002884 64 2007-01-03 00:00:00.000 4002756
002884 80 2006-03-06 00:00:00.000 4002756
002884 76 2005-08-10 00:00:00.000 4002756
002884 64 2004-09-02 00:00:00.000 4002756
007614 71 2008-04-21 00:00:00.000 4002756
007614 80 2007-12-19 00:00:00.000 4002756
007614 76 2007-07-30 00:00:00.000 4002756
007614 80 2007-01-04 00:00:00.000 4002756
007614 75 2006-12-06 00:00:00.000 4002756
007614 66 2006-08-29 00:00:00.000 4002756
007614 68 2006-04-09 00:00:00.000 4002756
007614 83 2005-08-31 00:00:00.000 4002756
007614 88 2004-09-24 00:00:00.000 4002756
==========================
==========
==========
==========
==========
===
The above set of data is the result of a query
SELECT StoreID, Score, Date, Area
FROM Structure
WHERE Area IN ('4002756')
ORDER BY StoreID, Date DESC
As can be seen, this is a listing of all the scores of the different restaurants in a particular region.
The following SQL returns only the Store IDs of the set of data.
SELECT DISTINCT StoreID
FROM Structure
WHERE RptOperID IN ('4002756')
StoreID
002884
007614
In this case there are only two stores.
I need to run a query that will return the top 6 results for each restaurant for the data at the top. Is there a 'for each' type of command? Or how else would be the best way to accomplish this?
Answer : SQL - For Each statement?
something like this:
select * from
(
select ranking = ranking = dense_rank() over (partition by storeid order by score desc), *
from structure
) a
where ranking <= 6
Random Solutions
Access Checking for duplicates , Help with "You can't save this record at this time"
2003 Prolaint ML370 looping during startup System License Violation.
Does anyone know of an Microsoft Access Documentation Program?
OUTLOOK 2003 is not working with ISA 2006
Row size limit reached
REMOVING TIMESTAMP FROM A DATE FIELD
Event ID 1001 BSOD System Reboot After BugCheck Windows XP
reuse code ,forms from other database without copy
How would I extract one of each number in an excel column that contains many copies of hundreds of numbers?
Sharepoint - Edit existing document error