Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Filter Data by Hour

$
0
0

Good Morning!

I have a query that gathers all the sales data for the day. There is a column on the SalesEntries table (SalesEntries.TimeStamp) that denotes the time the sale was finalized.

I need help on creating a Sales X Hour report that allows me to filter that sales data by hour. Here is a basic representation of my query:

SELECT

Se.ItemTotal

FROM SalesEntries Se

WHERE Se.TimeStamp BETWEEN @StartDate and @EndDate

My problem is that I am tempted to use sub-queries that just filter the sales data by hour but I feel that it would be grossly inefficient and that there is probably an easier way.

Ultimately, I am looking for..

09:00 AM - 10:00 AM$1542.58

10:00 AM - 11:00 AM $1279.24

Any help you can provide would be amazing.

Patrick


Patrick Regis


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>