Advertisement
Advertisement
| 06.24.2008 at 08:41AM PDT, ID: 23511420 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: |
drop table #tmpCustomer
drop table #tmpData
-- get Agents who belong to super agent 29500
SELECT tbl_Customer.IDAgent, tbl_CustomerAccount.Balance
into #tmpCustomer
FROM tbl_Customer WITH (nolock) INNER JOIN
tbl_CustomerAccount WITH (nolock) ON tbl_Customer.IDUtente = tbl_CustomerAccount.IDUtente
WHERE tbl_Customer.IDSuperAgent = '29500'
and tbl_Customer.IDTypeOfAccount = 2
group by tbl_Customer.IDAgent, tbl_CustomerAccount.Balance
order by tbl_Customer.IDAgent
-- get all agents under the above agents (who sit under super agent 29500) captured in the query above
SELECT tbl_Customer.IDAgent, tbl_Customer.Name, tbl_Customer.Surname, tbl_CustomerAccount.Balance
into #tmpData
FROM tbl_Customer WITH (nolock) INNER JOIN
tbl_CustomerAccount WITH (nolock) ON tbl_Customer.IDUtente = tbl_CustomerAccount.IDUtente
INNER JOIN #tmpCustomer tmp on tmp.IDAgent = u.IDSuperAgent
WHERE (tbl_Customer.IDAgent in u.IDSuperAgent) --<---- where I need help not sure how to query against the list in tmpcustomer
and tbl_Customer.IDTypeOfAccount = 2 and tbl_Customer.IDSuperAgent is not null
group by tbl_Customer.IDAgent, tbl_Customer.Name, tbl_Customer.Surname, tbl_CustomerAccount.Balance
-- get all agents data and under agents combined
Select distinct tmp.IDAgent, tmp.Name, tmp.Surname, sum(tmp.Balance + cu.Balance)
from tbl_Customer as u with (nolock) inner join
tbl_CustomerAccount as cu with (nolock) ON tbl_Customer.IDAgent = tbl_CustomerAccount.IDUtente
WHERE tbl_Customer.IDSuperAgent = '29500'
and tbl_Customer.IDTypeOfAccount = 2
group by tmp.IDAgent, tmp.Name, tmp.Surname
|