You are on page 1of 2

select a.cd_issubmitted as status,c.cd_departmentname as deptname,d.

cd_locationn
ame as locname, e.cd_statname as statname,b.cd_compliancename as compname,'Ext'
as comptype, a.cd_duedate as duedate,a.cd_dtsubmission as compliedon,f.cd_period
icity as periodicity,f.cd_hoduserid, f.cd_pruserid,d.cd_locationid, c.cd_departm
entid, b.cd_complianceid, a.cd_compinstanceid,f.cd_delegatedto,e.cd_statid,f.cd_
delgfrom,f.cd_delgto , g.cd_Companyname,g.cd_Companyid ,h.cd_buname,h.cd_buid ,i
.cd_projectname, i.cd_pmid,a.cd_totalAttach,f.cd_isattachmandatory,a.cd_remarks
,unq.cd_section_name,unq.cd_chapter_name,act.cd_actname,unq.cd_return_form_name
,unq.cd_penality,pri.cd_value, sevr.cd_value,pri.cd_subkey,sevr.cd_subkey,a.CD_
LASTESCLVL, COUNT(am.cd_locationid) as attach from cd_cischedule a left outer j
oin CD_ATTACHFILEMAP am on am.cd_locationid=a.cd_locationid and am.cd_compliance
id=a.cd_complianceid and am.cd_compinstanceid=a.cd_compinstanceid and am.cd_Comp
anyid=a.cd_companyid and am.cd_buid=a.cd_buid and am.cd_pmid=a.cd_pmid and a.CD_
DUEDATE=am.CD_DUEDATE,cd_compliancemaster b,cd_departmentmaster c,cd_locationmas
ter d,cd_statagency e,cd_Complianceinstance f ,cd_companymaster g ,cd_bumaster
h, cd_projectmaster i, cd_DEPTAdmin da ,cd_actmaster act,cd_unqcomp unq ,cd_us
ermaster pr,cd_usermaster hod,cd_configuration pri,cd_configuration sevr where a
.cd_locationid = f.cd_locationid and a.cd_complianceid = f.cd_complianceid and
a.cd_compinstanceid = f.cd_compinstanceid and f.cd_complianceid = b.cd_complia
nceid and b.cd_departmentid = c.cd_departmentid and a.cd_locationid = d.cd_loc
ationid and b.cd_externalstaagency = e.cd_statid and (a.cd_duedate) >= ('11/0
1/2010') and (a.cd_duedate) < ('12/01/2010') and c.cd_departmentid=da.cd_depart
mentid and (da.cd_userid)= 53 and b.cd_iscompinternal = 0 and g.cd_Companyid =
f.cd_companyid and h.cd_buid = f.cd_buid and i.cd_pmid = f.cd_pmid and f.cd_is
active = 1 and act.cd_actid = unq.cd_actid and unq.cd_unqcompid = f.cd_unqc
ompid and pri.cd_key=22 and sevr.cd_key=23 and pri.cd_subkey=unq.cd_priorityid
and sevr.cd_subkey=unq.cd_seviourityid and pr.cd_userid = f.cd_pruserid and ho
d.cd_userid = f.cd_hoduserid group by a.cd_issubmitted ,c.cd_departmentname ,d
.cd_locationname , e.cd_statname ,b.cd_compliancename ,'Ext', a.cd_duedate ,a.cd
_dtsubmission,f.cd_periodicity ,f.cd_hoduserid, f.cd_pruserid,d.cd_locationid, c
.cd_departmentid, b.cd_complianceid, a.cd_compinstanceid,f.cd_delegatedto,e.cd_s
tatid,f.cd_delgfrom,f.cd_delgto , g.cd_Companyname,g.cd_Companyid ,h.cd_buname,h
.cd_buid ,i.cd_projectname, i.cd_pmid,a.cd_totalAttach,f.cd_isattachmandatory,a.
cd_remarks ,unq.cd_section_name,unq.cd_chapter_name,act.cd_actname,unq.cd_retur
n_form_name,unq.cd_penality,pri.cd_value, sevr.cd_value,pri.cd_subkey,sevr.cd_s
ubkey,a.CD_LASTESCLVL union select a.cd_issubmitted as status,c.cd_departmentna
me as deptname,d.cd_locationname as locname, e.cd_departmentname as statname,b.
cd_compliancename as compname,'Int' as comptype, a.cd_duedate as duedate,a.cd_d
tsubmission as compliedon,f.cd_periodicity as periodicity,f.cd_hoduserid, f.cd_
pruserid,d.cd_locationid, c.cd_departmentid, b.cd_complianceid, a.cd_compinstanc
eid,f.cd_delegatedto,CHAR(e.cd_departmentid),f.cd_delgfrom,f.cd_delgto , g.cd_Co
mpanyname,g.cd_Companyid ,h.cd_buname,h.cd_buid ,i.cd_projectname, i.cd_pmid,a.c
d_totalAttach,f.cd_isattachmandatory,a.cd_remarks ,unq.cd_section_name,unq.cd_c
hapter_name,act.cd_actname,unq.cd_return_form_name,unq.cd_penality,pri.cd_value,
sevr.cd_value,pri.cd_subkey,sevr.cd_subkey,a.CD_LASTESCLVL, COUNT(am.cd_locati
onid) as attach from cd_cischedule a left outer join CD_ATTACHFILEMAP am on am.
cd_locationid=a.cd_locationid and am.cd_complianceid=a.cd_complianceid and am.cd
_compinstanceid=a.cd_compinstanceid and am.cd_Companyid=a.cd_companyid and am.cd
_buid=a.cd_buid and am.cd_pmid=a.cd_pmid and a.CD_DUEDATE=am.CD_DUEDATE,cd_compl
iancemaster b,cd_departmentmaster c,cd_locationmaster d, cd_departmentmaster e,
cd_Complianceinstance f, cd_companymaster g ,cd_bumaster h, cd_projectmaster i ,
cd_DEPTAdmin da ,cd_actmaster act,cd_unqcomp unq ,cd_usermaster pr,cd_usermas
ter hod,cd_configuration pri,cd_configuration sevr where a.cd_locationid = f.cd_
locationid and a.cd_complianceid = f.cd_complianceid and a.cd_compinstanceid =
f.cd_compinstanceid and f.cd_complianceid = b.cd_complianceid and b.cd_intern
aldepartmentid = c.cd_departmentid and a.cd_locationid = d.cd_locationid and b
.cd_internaldepartmentid = e.cd_Departmentid and (a.cd_duedate) >= ('11/01/201
0') and (a.cd_duedate) < ('12/01/2010') and c.cd_departmentid=da.cd_departmenti
d and (da.cd_userid)= 53 and b.cd_iscompinternal = 1 and g.cd_Companyid = f.
cd_companyid and h.cd_buid = f.cd_buid and i.cd_pmid = f.cd_pmid and f.cd_isact
ive = 1 and act.cd_actid = unq.cd_actid and unq.cd_unqcompid = f.cd_unqcompi
d and pri.cd_key=22 and sevr.cd_key=23 and pri.cd_subkey=unq.cd_priorityid and
sevr.cd_subkey=unq.cd_seviourityid and pr.cd_userid = f.cd_pruserid and hod.cd
_userid = f.cd_hoduserid group by a.cd_issubmitted ,c.cd_departmentname ,d.cd_
locationname , e.cd_departmentname ,b.cd_compliancename,'Int' , a.cd_duedate,a
.cd_dtsubmission ,f.cd_periodicity ,f.cd_hoduserid, f.cd_pruserid,d.cd_location
id, c.cd_departmentid, b.cd_complianceid, a.cd_compinstanceid,f.cd_delegatedto,C
HAR(e.cd_departmentid),f.cd_delgfrom,f.cd_delgto , g.cd_Companyname,g.cd_Company
id ,h.cd_buname,h.cd_buid ,i.cd_projectname, i.cd_pmid,a.cd_totalAttach,f.cd_isa
ttachmandatory,a.cd_remarks ,unq.cd_section_name,unq.cd_chapter_name,act.cd_act
name,unq.cd_return_form_name,unq.cd_penality,pri.cd_value, sevr.cd_value,pri.cd
_subkey,sevr.cd_subkey,a.CD_LASTESCLVL order by status,duedate

You might also like