I am trying to order by the posting_dte in my database, but I am getting the following error:
ORA-00979: not a GROUP BY expression SELECT a.POSITION_ID as position_id ,max(a.JOB_DESC) as job_desc ,max(a.SKILL_DESC) as skill_desc ,max(a.EDUC_EXP_DESC) as educ_exp_desc ,max(a.KEYWORD_DESC) as keyword_desc ,max(a.TITLE_DESC) as title_desc ,max(a.SALARY_START_AMT) as salary_start_amt ,max(a.SALARY_END_AMT) as salary_end_amt ,max(to_char(a.POSTING_DTE,'mm/dd/yyyy')) as posting_dte ,max(to_char(a.END_DTE,'mm/dd/yyyy')) as end_dte ,max(a.CONTACT_ID) as contact_id ,max(a.CATEGORY_ID) as category_id ,max(a.FACILITY_ID) as facility_id ,max(a.SCHEDULE_TYP) as schedule_typ ,max(a.STAT_IND) as stat_ind ,max(b.SEQ_NBR) as seq_nbr ,max(b.LOCN_NBR) as locn_nbr ,max(b.MARKET_NBR) as market_nbr ,max(b.CITY) as city ,b.ST from sysadm.injob_jobs a, sysadm.injcl_corplocn b WHERE a.position_id = b.position_id(+) AND a.stat_ind in ('A','I', 'O', 'B') AND a.posting_dte <= sysdate group by a.position_id, b.ST order by a.posting_dte desc
It works fine if I order by a.position_id, but fails if I want to order by any other column. Can someone please help?
Thanks!
P.S. Here is my actual select statement:
$sqlstmt=" SELECT a.POSITION_ID as position_id
,max(a.JOB_DESC) as job_desc
,max(a.SKILL_DESC) as skill_desc
,max(a.EDUC_EXP_DESC) as educ_exp_desc
,max(a.KEYWORD_DESC) as keyword_desc
,max(a.TITLE_DESC) as title_desc
,max(a.SALARY_START_AMT) as salary_start_amt
,max(a.SALARY_END_AMT) as salary_end_amt
,max(to_char(a.POSTING_DTE,'mm/dd/yyyy')) as posting_dte
,max(to_char(a.END_DTE,'mm/dd/yyyy')) as end_dte
,max(a.CONTACT_ID) as contact_id
,max(a.CATEGORY_ID) as category_id
,max(a.FACILITY_ID) as facility_id
,max(a.SCHEDULE_TYP) as schedule_typ
,max(a.STAT_IND) as stat_ind
,max(b.SEQ_NBR) as seq_nbr
,max(b.LOCN_NBR) as locn_nbr
,max(b.MARKET_NBR) as market_nbr
,max(b.CITY) as city
,b.ST
from sysadm.injob_jobs a,
sysadm.injcl_corplocn b
WHERE a.position_id = b.position_id(+)
AND a.stat_ind in ('A','I', 'O', 'B')
AND a.posting_dte <= sysdate
group by a.position_id, b.ST
order by a.posting_dte desc";