Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Return only one value based on columns in SQL

Posted on 2009-07-15
2
Medium Priority
?
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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