June results List
Rank |
|
Partner |
performance |
sign |
interview |
daily goals |
1 |
|
Du Yan Flower |
12367 |
2 |
0 |
View Target |
2 |
|
Zhengdongjie |
2345 |
1 |
0 |
View Target |
3 |
|
Huang |
345 |
1 |
1 |
View Target |
4 |
|
Test |
0 |
0 |
0 |
View Target |
5 |
|
Li Xia |
0 |
0 |
0 |
View Target |
6 |
|
Wang Ke |
0 |
0 |
1 |
View Target |
7 |
|
Shuang |
0 |
0 |
0 |
View Target |
When I get the above business requirements, I immediately think about how the SQL statement should be written.
Try a simple table left and right link query to join right join, obviously the problem is not so simple, data query error, and then get Big Bird guidance, recorded.
Select A.yyry_xiaotxiang, A.YYRY_ID,A.YYRY_XMING,C.CC,D.DD, B.BB
From Yyry A
Left JOIN (SELECT COUNT (mtjl_id) Bb,mtjl_yyryid
From MTJL
Where year (now ()) =year (Mtjl_yysjian) and Month (now ()) =month (Mtjl_yysjian)
Group BY Mtjl_yyryid) b on A.yyry_id=b.mtjl_yyryid
Left JOIN (select Xiaoshouid,sum (Khsh_yji) cc from KHSHDJB
Where year (now ()) =year (Khsh_jrusjian) and Month (now ()) =month (Khsh_jrusjian) GROUP BY
XIAOSHOUID) C
On A.yyry_id=c.xiaoshouid
Left JOIN (SELECT COUNT (khsh_id) dd,xiaoshouid
From KHSHDJB
Where year (now ()) =year (Khsh_jrusjian) and Month (now ()) =month (Khsh_jrusjian)
Group by Xiaoshouid) d on a.yyry_id=d.xiaoshouid where A.yyry_jsemcheng = ' transfer ' and a.yyry_id > 0 ORDER BY c.cc Desc
This is a three-table search, respectively, the Yyry (operator's table) of the image, ID, name, KHSHDJB (customer after-sales registration form) operators of the monthly results of the total, the number of orders, MTJL (interview record table) operators of the month total number of interviews.