SQL Server Group By and Left Outer Join Custom result set -


i have 2 tables rdc , cons_status, rdc has unique column in rdc_consno. , against consignment number, there multiple records in cons_status table depicted in image attached. want write query in 1 record joined status maximum sts_id. using sql server 2012.

select sts_id,rdc_consno,sts_status , rdc_date,rdc_customer,dest_name rdc left outer join cons_status on rdc_consno=sts_consno inner join destination on dest_id=rdc_destination rdc_consno='hd88300' order sts_id 

database diagram tables

enter image description here

don't forget prefix columns

select ?? rdc outer apply (select top 1 * cons_status rdc.rdc_consno = sts_consno order sts_id desc ) inner join destination d on d.dest_id=rdc.rdc_destination  rdc.rdc_consno='hd88300' order a.sts_id 

Comments

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

xml - How do I use an xdoxslt variable inside xsl code, in BI Publisher? -