troubleshooting Question

TOP Record By Group

Avatar of MBoy
MBoy asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008
15 Comments1 Solution228 ViewsLast Modified:
The following SP works fine for grabbing all the records I need.  I need to modify this SP to return only the TOP [Event].[2] per group.  Thanks in advance.
CREATE PROCEDURE [dbo].[GetAllLocationsWithVehicleName]
AS
BEGIN
 
	 SELECT
		[GPRSDevice].[GPRSDeviceHardwareID],
		[Vehicle].[VehicleName],
		[Event].[4],
		[Event].[3],
		[Event].[2]
     FROM  [GPRSDevice], [Vehicle], [Event]
	 WHERE [GPRSDevice].[VehicleID] = [Vehicle].[VehicleID]
		AND [GPRSDevice].[GPRSDeviceHardwareID] = [Event].[1]
	 ORDER BY [Vehicle].[VehicleName]
 
END
GO
ASKER CERTIFIED SOLUTION
Aneesh
Database Consultant
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros