-
Problem with Correlated Sub Query
I have a table that lists owner_id, incident_id, and date_closed. I am trying to write a query that returns the owner, a count of Incidents, and how many have closed dates. Open incidents have null values for date_closed.
When I run this query it returns
ERROR at line 6:
ORA-00979: not a GROUP BY expression
Can someone let me know where I went wrong.
Thanks in advance for your help.
select
owner_id, count(incident_id),
NVL(
(
Select
count(incident_id)
from
incident inc1
where
inc1.owner_id = inc.owner_id and
inc1.date_closed is null
),0) As runningtotal
from
incident inc
group by
owner_id
order by
owner_id
Edit/Delete Message
-
Don't you really want this?
select owner_id, count(incident_id), count(date_closed)
from incident inc
group by owner_id
order by owner_id
-
Yes that does work and is much simpler than what I was doing.
I guess this was one of those times where one starts down the wrong path and makes things way harder then they needed to be.
Thank you for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|