jeudi 18 août 2016

Get Max Entry_Sr_no from another table in SP

I have a SP, which gives me mkey and doc_no from one table.

Now I want to get the max of entry_sr_no of that respective mkey from the another table.

Here is my SP

alter procedure set_auto_action
    as 
        begin

            select mkey, doc_no from inward_doc_tracking_hdr 
           where status_flag not in (5,13)      
    end

I want to get max from inward_doc_tracking_trl table

The relation of both the table is something like below

inward_doc_tracking_hdr table mkey is equal to inward_doc_tracking_trl table ref_mkey

kindly suggest how to do this in SP

Aucun commentaire:

Enregistrer un commentaire