Home > database >  The great god help me to look at the SQL which is wrong? With Oracle
The great god help me to look at the SQL which is wrong? With Oracle

Time:09-26

The SELECT tu. User_name, NVL (SUM (FDS) MONEY), 0) MONEY
The FROM F_DRUG_SALES FDS
INNER JOIN T_USER_PROPERTY tu
ON the FDS. BILLING_PERSON_ID=tu. ID
INNER JOIN T_DATES td
ON the FDS. DATE_ID=td. ID
WHERE 1=1
AND the FDS. BILLING_OFFICE_ID IN (13287)
AND td. CAL_DATE & gt;
='2017-05-01'AND td. CAL_DATE & lt;
='2017-05-31'GROUP BY tu. User_name
The ORDER BY NVL (SUM (FDS) MONEY), 0) DESC
WHERE ROWNUM & lt;=10

CodePudding user response:

A little modification can
 
The select tu. User_name, NVL (sum (FDS) money), 0) money
The from f_drug_sales FDS
Inner join t_user_property tu
On the FDS. Billing_person_id=tu. Id
Inner join t_dates td
On the FDS. Date_id=td. Id
Where the FDS. Billing_office_id in (13287)
And td. Cal_date & gt;
='2017-05-01'And td. Cal_date & lt;
='2017-05-31'And rownum & lt;=10
Group by tu. User_name
The order by NVL (sum (FDS) money), 0) desc

CodePudding user response:

Adjust the:
 
The select user_name, money
The from (select tu user_name, NVL (sum (FDS) money), 0) money
The from f_drug_sales FDS
Inner join t_user_property tu
On the FDS. Billing_person_id=tu. Id
Inner join t_dates td
On the FDS. Date_id=td. Id
Where the FDS. Billing_office_id in (13287)
And td. Cal_date & gt;
='2017-05-01'And td. Cal_date & lt;
='2017-05-31'Group by tu. User_name
The order by NVL (sum (FDS) money), 0) desc
)
Where rownum & lt;=10

CodePudding user response:

Problem solved, building knot stick!
  • Related