Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date Variables

Author  Topic 

SQL-Hack
Starting Member

1 Post

Posted - 2015-03-26 : 18:02:43
I have this SQL Query:
==============================

select ITEM_NO,
SUM(QTY_SOLD)
from CCDB.dbo.PS_TKT_HIST_LIN
where
BUS_DAT > '12/31/2013'
and
BUS_DAT < '01/01/2015'
group by ITEM_NO;

===============================

This is retail business and the table referenced is the sales ticket line table. There is one ticket line record for every item number under each sales ticket.

I use this query to compile quantity sold during a given time period (in the above example it would collect and group qty sold from ticket lines for the entire year 2014).

I then extract the SQL results and put it in an Access table to report on. There are other things on the report of course, but this is the root of my issue.

My problem is that the business wants me and my Access Database out of the loop. They want to be able to select the dates themselves and pull the qty sold from the date range of their choice.

I can make the report they need in SAP Crystal Reports but I am stuck on the best way to get the dates as Variables so they can put them in. Can someone nudge me in the right direction?

I hope this makes this sense!

Thank you!!

kostya1122
Starting Member

15 Posts

Posted - 2015-03-26 : 20:09:02
in crystal reports create report using command
paste the query into command.
inside the command create 2 parameters start and end with value type as date.
replace your hard coded dates with this parameters.
Go to Top of Page

huangchen
Starting Member

37 Posts

Posted - 2015-04-02 : 05:52:17
unspammed
Go to Top of Page
   

- Advertisement -