ORA-01791-Excellent and orderly

I want to get excellent "SkillCategory"

and sort byid

here is the script:

SELECT  distinct EC.SKILL_CATEGORY from ETOPS_CHECK_FORM E
INNER JOIN EC_FORM_SKILL EC
ON EC.EC_FORM_ID=E.ID group by EC.SKILL_CATEGORY ORDER BY EC.ID

      

what am I doing wrong?

+3


source to share


4 answers


The problem is that you have to decide which ID to sort. Remove distinct

and then use the aggregation function in order by

:



SELECT EC.SKILL_CATEGORY
FROM ETOPS_CHECK_FORM E INNER JOIN
     EC_FORM_SKILL EC
     ON EC.EC_FORM_ID = E.ID
GROUP BY EC.SKILL_CATEGORY
ORDER BY MIN(EC.ID);

      

+3


source


If you only want individual records without using aggregate functions use DISTINCT rather than GROUP BY

Try the following:



SELECT DISTINCT EC.SKILL_CATEGORY 
FROM ETOPS_CHECK_FORM E
INNER JOIN EC_FORM_SKILL EC ON EC.EC_FORM_ID = E.ID 
ORDER BY EC.ID;

      

0


source


SELECT  distinct EC.SKILL_CATEGORY 
FROM ETOPS_CHECK_FORM E
  INNER JOIN EC_FORM_SKILL EC
          ON EC.EC_FORM_ID=E.ID 
GROUP BY EC.SKILL_CATEGORY ASC
ORDER BY MAX(EC.ID)

      

0


source


I'm wondering what you really want to do ... ^^ But if you run the script below, could you please tell us if there is the result you are hoping for:

Select ec.skill_category as sc
from EC_FORM_SKILL ec
group by sc;

      

See you later.

0


source







All Articles