Solved

Return only one value based on columns in SQL

Posted on 2009-07-15
2
216 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now