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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -