SELECT tu.user_name, NVL(SUM(fds.MONEY), 0) MONEY
FROM F_DRUG_SALES fds
INNER JOIN T_USER_PROPERTY tu
ON fds.BILLING_PERSON_ID = tu.ID
INNER JOIN T_DATES td
ON fds.DATE_ID = td.ID
WHERE 1 = 1
AND fds.BILLING_OFFICE_ID IN (13287)
AND td.CAL_DATE >= '2017-05-01'
AND td.CAL_DATE <= '2017-05-31'
GROUP BY tu.user_name
ORDER BY NVL(SUM(fds.MONEY), 0) DESC
WHERE ROWNUM <= 10
uj5u.com熱心網友回復:
稍微改下就可以了
select tu.user_name, nvl(sum(fds.money), 0) money
from f_drug_sales fds
inner join t_user_property tu
on fds.billing_person_id = tu.id
inner join t_dates td
on fds.date_id = td.id
where fds.billing_office_id in (13287)
and td.cal_date >= '2017-05-01'
and td.cal_date <= '2017-05-31'
and rownum <= 10
group by tu.user_name
order by nvl(sum(fds.money), 0) desc
uj5u.com熱心網友回復:
調整下:
select user_name,money
from(select tu.user_name, nvl(sum(fds.money), 0) money
from f_drug_sales fds
inner join t_user_property tu
on fds.billing_person_id = tu.id
inner join t_dates td
on fds.date_id = td.id
where fds.billing_office_id in (13287)
and td.cal_date >= '2017-05-01'
and td.cal_date <= '2017-05-31'
group by tu.user_name
order by nvl(sum(fds.money), 0) desc
)
where rownum <= 10
uj5u.com熱心網友回復:
問題解決了,此樓結貼!
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/81521.html
標籤:開發
