Solved

Return only one value based on columns in SQL

Posted on 2009-07-15
2
225 Views
Last Modified: 2012-05-07
I'm trying to only return the STOREID and POLL_TIME in a query based on the @StartDate. Each STOREID has multiple entries for each date so I'm getting something like this currently:

StoreID     POLL_TIME
1               5:57
1               6:23
1               7:23
2               1:42
2               4:23


I only want to return this:

StoreID     POLL_TIME
1               7:23
2               4:23

Any help here?
SELECT 
	SUMMARY.STOREID, 
	SUMMARY.POLL_TIME
FROM 
	SUMMARY 
WHERE 
	SUMMARY.Current_Batch_Date = @StartDate
	
ORDER BY 
	STOREID

Open in new window

0
Comment
Question by:mattkovo
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24864115
SELECT
      SUMMARY.STOREID,
      MAX(SUMMARY.POLL_TIME) Poll_Time
FROM
      SUMMARY
WHERE
      SUMMARY.Current_Batch_Date = @StartDate
GROUP BY    STOREID  
ORDER BY
      STOREID
0
 

Author Closing Comment

by:mattkovo
ID: 31603997
Genius!  Thanks!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question