- Aug 31, 2001
- 21,205
- 165
- 106
SQL newb here looking for some help
I have the following query
which returns the following (colums in red are indexes)
What I need is to select the orange highlighted rows - which is:
for each combination of MPH_PROC_CD, MPH_MOD_PATTERN_CD, and MPH_EFF_CYMD, select the row with the highest MPH_SEQ_NBR
I am not sure how to do this. Any tips?
I have the following query
Code:
SELECT MPH_SITE_ID,
MPH_BASE_CONTRACT_NBR,
MPH_PROC_CD,
MPH_MOD_PATTERN_CD,
MPH_MOD_PRICE_AMT,
MPH_RSN_CD,
MPH_EFF_CYMD,
MPH_EXP_CYMD,
MPH_SEQ_NBR,
MPH_FM_CYMD,
MPH_FM_USER_CD
FROM MPH_DATA
WHERE MPH_SITE_ID = 'ETX'
AND (MPH_BASE_CONTRACT_NBR BETWEEN
00003 AND 00003)
ORDER BY MPH_PROC_CD DESC,
MPH_MOD_PATTERN_CD DESC,
MPH_EFF_CYMD DESC,
MPH_SEQ_NBR DESC
What I need is to select the orange highlighted rows - which is:
for each combination of MPH_PROC_CD, MPH_MOD_PATTERN_CD, and MPH_EFF_CYMD, select the row with the highest MPH_SEQ_NBR
I am not sure how to do this. Any tips?
