We help IT Professionals succeed at work.
Get Started

SQL Sub Query Result Grouping

399 Views
Last Modified: 2012-05-06
Experts

I have a simple select query that I use to produce reports on repeat trouble tickets.  This is the output of the query, also attached on the spreadsheet.  What I need in the reports column is the total of 1858+137 and then in the repeat_tickets column I want the 137 all on the same row.  The query I am using is also attached.

MONTH      SRC_SYS      VZ_SVC_TYPE_1      REPORTS      REPEAT_TICKETS
1/1/2009      WFA CP           DS0                        1858      
1/1/2009      WFA CP            DS0                        137             137

select trunc(CLOSED, 'MON')Month,SRC_SYS,vz_svc_type_1,count (1) Reports,
Case When (repeat)>=('1') then Count (1) end Repeat_tickets
from mtc.jc_rfr_mtd_2008
where trunc(closed,'MON')= '01-JAN-2009'
group by trunc(CLOSED, 'MON'),SRC_SYS,vz_svc_type_1,repeat

Open in new window

SQL-Example.xls
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE