ora-00979 not a GROUP BY expression help spool
سؤال
SET colsep '|'
SET echo OFF
SET feedback OFF
SET linesize 1000
SET pagesize 0
SET sqlprompt ''
SET trimspool ON
SET headsep OFF
spool monitor.csv
SELECT error_id, '|', error_desc, '|', b.control_by
FROM error a, component_info b
WHERE a.error_id IN (
SELECT error_id FROM component_thresh JOIN component_info USING (component_id))
GROUP BY b.control_by
ORDER BY a.error_desc
/
I need to group by a column in a different table then order it by error_desc then spool out results.
Edit: Ah! I needed to order by both.
المحلول
It seems that you want to order all the rows with the same control_by
together, to be able to browse them. What GROUP BY
attempts to do is put everything into one row, and it doesn't seem like this is what you want.
You can use ORDER BY clause instead of GROUP BY. This will put all the rows with the same control_by
to appear together. Also, you can GROUP BY b.control_by, a.error_id
; and get the same result. The best option is to use ORDER BY control_by, error_desc
.
select error_id, '|', error_desc, '|', b.control_by from
error a, component_info b where
a.error_id in (
select error_id
from component_thresh
join component_info using(component_id)
)
order by b.control_by, a.error_desc;
/
This should do the trick for your client.
لا تنتمي إلى StackOverflow