SELECT DISTINCT a.姓名,round(回款额,2) AS 字段 FROM (SELECT 姓氏||名字 as 姓名,sum(单价*数量*(1-折扣)) AS 销售额 FROM S雇员,s订单明细,"S订单" WHERE S雇员.雇员ID="S订单"."雇员ID" AND "S订单"."订单ID"="S订单明细"."订单ID" GROUP by "姓氏"||"姓名" ORDER BY SUM("单价"*数量*(1-"折扣"))DESC) a , (SELECT "姓氏"||"名字" AS "姓名",sum("单价"*"数量"*(1-"折扣"))AS 回款额 FROM "S雇员","S订单明细","S订单" WHERE "S雇员"."雇员ID"="S订单"."雇员ID"and "S订单"."订单ID"="S订单明细"."订单ID" AND "S订单"."是否已付"='是' GROUP BY "姓氏"||"姓名" ORDER BY SUM("单价"*"数量"*(1-"折扣")) DESC) AS b,"回款率" WHERE a."姓名"=b."姓名" AND a."姓名"="雇员姓名" ORDER BY 字段 DESC ----------------------- 上述是图表联动TOP10的回款金额与销售金额sql语句。有2个部分不明白,一是红色部分代表的是取回款金额的前10条数据吗?round不是四舍五入函数吗?二是一定要在 b,的后面加上“回款率”这又是为什么? 求助大佬解答 |