Here’s my table definition:
tblTrans
PK - trans_id (int)
- user_id_fk (int)
- trans_created (datetime)
- trans_amount (money)
I want to sum all sales data for a given day, and return it as NumberOfTransactions,TotalDollars
I have the following SQL query that I want to move to a stored procedure that takes MM/DD/YYYY as a parameter.
The query works, I’m just not sure how to pass in the parameter.
SELECT Cast(count(*) as varchar(8)) + ','
+ Cast(Sum(trans_amount) as varchar(8)) as SalesData
FROM PD_Transaction
WHERE pd_Trans_CreatedOn BETWEEN '20130122' 00:00:00.000' AND '20130122 23:59:59.997'
I want to create this as a stored procedure, and pass in just the date.
Thank you!
If passing one date only: