Joined: 23 Jul 2008 Posts: 29 Location: Little Rock - Arkansas
SELECT ICN, REL_LINE_NBR, PAYMENT_AMT, CONTRACT_NBR, CLEAN_CLAIM_IND, CLAIM_TYPE, ASSIGN_CODE, EMC_INDIC, CLAIM_LINE_STATUS, MAX (PAID_DATE) PAID, MIN (CLEAN_DATE) CLEAN, MIN (CLAIM_RECEIVED_DT) RECEIVE, COUNT(*) CTR
FROM DSNW.DWS_US_AMISYS_CLM
GROUP BY ICN, REL_LINE_NBR, PAYMENT_AMT, CONTRACT_NBR, CLEAN_CLAIM_IND, CLAIM_TYPE, ASSIGN_CODE, EMC_INDIC, CLAIM_LINE_STATUS
ORDER BY ICN
WITH UR
Question :- The above is my sql query, it is having min, max functions and at the same time i am doing GROUP BY based on some columns, here if i give GROUP BY on some columns only which are present in SELECT query its giving message GROUPING INCONSISTENT, but in GROUP BY if i give all the columns present in SELECT QUERY then it is working fine.
So in a GROUP BY clause is it mandatory to give all the columns present in SELECT query which are having aggregate functions like (max,min)???