Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for Report Help

Status
Not open for further replies.

CappsRLO

Vendor
Apr 18, 2007
31
US
I am utilizing the following query to deliver some numbers for a specific date range. Now I need to include the same data but without a date range into the same report. What would be the best way to do this?

SELECT company.company_name, COUNT(service_req.id) AS Expr1, cust_values.value_caption
FROM service_req INNER JOIN
sysaid_user ON service_req.submit_user = sysaid_user.user_name INNER JOIN
cust_values ON service_req.status = cust_values.value_key LEFT OUTER JOIN
company ON sysaid_user.company = company.company_id
GROUP BY company.company_name, service_req.insert_time, service_req.close_time, cust_values.value_caption, cust_values.list_name
HAVING (service_req.insert_time >= @start_date) AND (cust_values.list_name = N'Status') AND (service_req.insert_time <= @finish_date)
ORDER BY company.company_name
 
Do an if...else structure based on whether start and/or end date is populated is what I do. Hope that helps!
~Brett

--------------------------
Web/.net Programmer & DBA
Central PA
 
Clarification... I need to report that within a specific date range there were # Open Tickets. I then need to state how many Open Tickets that are TOTAL without a date range. The date/time will always be populated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top