sql - Get the group by on 2 column and date as latest -


i have 2 table , m fetching record below

enter image description here

the query

select   bmc.jcrs_mem_crs_code,          bmc.jcrs_mem_description,          bmc.jcrs_mem_date,          bjcm.jcrs_mast_title     bus_membercourse bmc inner join bus_journeymancoursemaster bjcm     on bmc.jcrs_mem_crs_code = bjcm.jcrs_mast_code    bmc.jcrs_mem_completed = 1          , bmc.jcrs_mem_mem_id = 5010 group bmc.jcrs_mem_crs_code,          bmc.jcrs_mem_description,          bmc.jcrs_mem_date,          bjcm.jcrs_mast_title 

but want need make group on jcrs_mem_crs_code , jcrs_mem_description , if 2 column data common want took latest date multiple dates. i.e. want pick row , ignore other rows.

you want max(date):

select   bmc.jcrs_mem_crs_code,          bmc.jcrs_mem_description,          max(bmc.jcrs_mem_date) jcrs_mem_date,          bjcm.jcrs_mast_title     bus_membercourse bmc inner join bus_journeymancoursemaster bjcm     on bmc.jcrs_mem_crs_code = bjcm.jcrs_mast_code bmc.jcrs_mem_completed = 1 ,   bmc.jcrs_mem_mem_id = 5010 group bmc.jcrs_mem_crs_code,          bmc.jcrs_mem_description,          bjcm.jcrs_mast_title 

Comments

Popular posts from this blog

python - Best design pattern for collection of objects -

go - serving up pdfs using golang -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -