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
how can i ident code in visual Foxpro 9.0
modify cangrow property dynamically
ODBC connection error
Opinion - best portable hard drive to backup SBS
Digging in to somebody else's stuff
Creating event "boxes" around a clock (powered by Events list)
I have a Windows Server 2003 OEM key, but only a Windows 2003 Server Enterprise Edition Disk. How can I use the Enterprise edition disk to install regular Server (non-enterprise)?
Where are my e-mail messages?
TextBox and Validation Rule
File Upload & Download using ASP.net 2.5 & MVC2.0