I want to get excellent "SkillCategory" and sort byid
"SkillCategory"
id
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?
The problem is that you have to decide which ID to sort. Remove distinct and then use the aggregation function in order by :
distinct
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);
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;
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)
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.