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.
| Author |
Topic |
|
rafaeljavellana
Starting Member
4 Posts |
Posted - 2008-11-14 : 14:33:53
|
Hello, good morning, I am new to SQL Queries, I have actually 5 queries that are being run when I do a reporting, on that query I have to input the DATE (BETWEEN date1 AND date1) on all the queries to filter the reports on that particular date. Now my question, is that possible to execute that 5 queries simultaneously? like for example, It will just ask for the "Date" then it will execute all the 5 queries together?Need help.Thanks.Rafael Javellana |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2008-11-14 : 14:41:38
|
| DECLARE @DatePar DATETIMESET @DatePar = '20080731'SELECT * FROM YOURFISTQUERY WHERE DATE1 = @DateParSELECT * FROM YOURSECONDQUERY WHERE DATE1= @DatePar |
 |
|
|
rafaeljavellana
Starting Member
4 Posts |
Posted - 2008-11-14 : 15:15:20
|
| like for example my query 1 like this:SELECT AVG(holdtime)/60.0 AS Average_Hold_TimeFROM dispositionWHERE (callstart >= {fn NOW()} - 1) AND (holdtime <> 0)query 2SELECT uc.description, r.usercode, COUNT(*) AS Expr1FROM dbo.result AS r INNER JOIN VoiceNet_Focus.dbo.Usercodes AS uc ON r.usercode = uc.usercodeWHERE (r.callstart BETWEEN '11/13/08' AND '11/15/08') AND (uc.project = 'IDL')--WHERE (r.callstart > '10/21/2008' ) AND (uc.project = 'IDL')GROUP BY uc.description, r.usercodeso it can be run together? it will ask for the start date and end date? then it will execute that 2 queries together? thanksrafael javellana |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-14 : 23:38:44
|
quote: Originally posted by rafaeljavellana like for example my query 1 like this:SELECT AVG(holdtime)/60.0 AS Average_Hold_TimeFROM dispositionWHERE (callstart >= {fn NOW()} - 1) AND (holdtime <> 0)query 2SELECT uc.description, r.usercode, COUNT(*) AS Expr1FROM dbo.result AS r INNER JOIN VoiceNet_Focus.dbo.Usercodes AS uc ON r.usercode = uc.usercodeWHERE (r.callstart BETWEEN '11/13/08' AND '11/15/08') AND (uc.project = 'IDL')--WHERE (r.callstart > '10/21/2008' ) AND (uc.project = 'IDL')GROUP BY uc.description, r.usercodeso it can be run together? it will ask for the start date and end date? then it will execute that 2 queries together? thanksrafael javellana
you cant make sql server prompt for inputs from user.However, wht you could do is write a procedure with parameters for dates and call it with reqd values.Also use GETDATE() instead of {fn NOW()} |
 |
|
|
|
|
|
|
|