0% found this document useful (0 votes)
7 views5 pages

Updated Queries

SQL

Uploaded by

poojanew
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Updated Queries

SQL

Uploaded by

poojanew
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

FOR DBFR

select * from at_product_master where fr_nonfr='DBFR';

select * from at_sales_persons where id=507064;

select * from at_sales_persons where mobile_no in (9996707093, 8295585382,


8295765151, 9729163877 );

select * from at_outlet_accum_data where KPI= 'dbfr'and DT= '2015-02-01' and ID


in(495676,

506253 , 648711, 659634 );

select Manager_ID, PERSON_ID from at_sales_person_tree where


start_date<='2015-02-01' and end_date > '2015-02-01' and person_id in (507064 );

FOR PERDBFR
FOR PERDBFR TGT:

For FSE

SELECT id, OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select PERSON_ID from at_sales_person_tree where MANAGER_ID =488820

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

For DIST

SELECT id, OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select person_id from at_sales_person_tree where manager_id in(

select PERSON_ID from at_sales_person_tree where MANAGER_ID =488755

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

SELECT person_id FROM sales_person WHERE PERSON_ID IN (

select person_id from sales_person_tree where MANAGER_ID in

(select person_id from sales_person_tree where MANAGER_ID =22648

and START_DATE <= CURRENT_DATE and end_date > CURRENT_DATE)


and START_DATE <= CURRENT_DATE and end_date > CURRENT_DATE);

For TM

SELECT id, OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select person_id from at_sales_person_tree where manager_id in (select PERSON_ID


from at_sales_person_tree where MANAGER_ID in(

select PERSON_ID from at_sales_person_tree where MANAGER_ID =488732

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

For ZSM

SELECT id, OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select person_id from at_sales_person_tree where manager_id in (select PERSON_ID


from at_sales_person_tree where MANAGER_ID in(select PERSON_ID from
at_sales_person_tree where MANAGER_ID in(

select PERSON_ID from at_sales_person_tree where MANAGER_ID =644775

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

For ZBM

SELECT id, OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select person_id from at_sales_person_tree where manager_id in (select PERSON_ID


from at_sales_person_tree where MANAGER_ID in(select PERSON_ID from
at_sales_person_tree where MANAGER_ID in(select PERSON_ID from
at_sales_person_tree where MANAGER_ID in(

select PERSON_ID from at_sales_person_tree where MANAGER_ID =670787

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

For CEO

SELECT id,OUTLET_tAG FROM at_sales_persons WHERE ID IN (

select person_id from at_sales_person_tree where manager_id in (select person_id


from at_sales_person_tree where manager_id in (

select person_id from at_sales_person_tree where manager_id in (select person_id


from at_sales_person_tree where manager_id in (select PERSON_ID from
at_sales_person_tree where MANAGER_ID in(

select PERSON_ID from at_sales_person_tree where MANAGER_ID =488670

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25')

and START_DATE <='2015-02-25' and end_date > '2015-02-25');

FOR PERDBFR STATUS

select ID,D0,MTD,TGT from at_outlet_accum_data where kpi='PERDBFR' and


DT='2015-02-01' and id in (489436, 489451, 489452, 489465, 489469, 489530,
493766, 489438, 489677, 490083 );

FOR 3iScore
select kpi,mtd,tgt,ach from at_tm_accum_data where kpi
in('LPRCT','PVC','BGROWTH','PERDBFR','PERDBC','PERSSO') and dt='2015-02-01'
and id=648552

select involscore,investscore,infrascore,scored from at_3i_score where


sales_person_id = 488739;

FOR iScore
select id,kpi,status from at_kpi_status where kpi
in('LPRCT','BGROWTH','PERDBFR','PERDBC','PERSSO') and
SALES_PERSON_ID=362050;

select * from at_involvement_score where SALES_PERSON_ID ='362050';

/////////////////////////////////////////////////////////////

For Base Growth


select person_id as dist from at_sales_person_tree where manager_id= 326870

and START_DATE <='2015-03-01' and END_DATE > '2015-03-01';

For Base Growth Status

select ID,LMTD,MTD,TGT from at_fse_accum_data where kpi='Bgrowth' and


DT='2015-03-01' and id in (362056, 362084, 362148, 362219, 362246, 362266,
362382, 362413, 362480, 362242, 362062, 362241);

select * from at_kpi_status where kpi='Bgrowth' and sales_person_id in (362056,


362062,

362084 ,362148, 362219, 362241, 362242, 362246, 362266, 362382, 362413,


362480);

Select sum(TGT) from at_sales_persons a, at_outlet_accum_data b where a.circle_id


= 11 and [Link] = '2015-05-01' and [Link] = 'BGROWTH' and [Link] = [Link];

163438
select TGT from at_ceo_accum_data where kpi='PERDBFR' and DT='2015-05-01'
and id = 163438;

SELECT * at_sales_persons WHERE ID IN (select PERSON_ID from


at_sales_person_tree where MANAGER_ID = 1300606 and START_DATE <='2015-05-
19' and end_date > '2015-05-19');

select person_id from at_sales_person_tree where start_date<='2015-05-19' and


end_date > '2015-05-19' and manager_id in (1300606);

select * from at_zbm_accum_data where kpi='BGROWTH' and DT='2015-05-01'


and id = 1300606;

You might also like