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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -