问这个SQL写法 ------解决方案-------------------- 各统计80%、90%、95%的用户----你这里头的百分比哪里来的? ------解决方案-------------------- select avg(saleamount) from
(select top 80 percent * from caiji) a
------解决方案-------------------- select top 80 percent * from 用戶表 order by newid() ------解决方案-------------------- 80%、90%、95%的用户基于什么标准啊。
SELECT userbm,AVG(saleamount) AS OrderAVG
FROM caiji
GROUP BY userbm
SELECT AVG(linetotal) FROM Sales.SalesOrderDetail AS sod TABLESAMPLE(80 PERCENT)
SELECT AVG(linetotal) FROM Sales.SalesOrderDetail AS sod TABLESAMPLE(90 PERCENT)
SELECT AVG(linetotal) FROM Sales.SalesOrderDetail AS sod TABLESAMPLE(95 PERCENT)
select top 80 percent AVG([购买量]) as [平均购买量] from caiji order by newid() ---80%
select top 90 percent AVG([购买量]) as [平均购买量] from caiji order by newid() ---90%
select top 95 percent AVG([购买量]) as [平均购买量] from caiji order by newid() ---95%
------解决方案--------------------
select userbm, avg(saleamount) from
(select top 80 percent* from caiji where order by newid())a
group by userbm --各统计80%的用户,购买量平均值。