表还是total_sales添加一项
表:
sql语句:
代码如下:
(SELECT a1.Name,a1.Sales,COUNT(a2.sales) Sales_Rank
FROM Total_Sales a1,Total_Sales a2
WHERE a1.Sales < a2.Sales or (a1.Sales=a2.Sales and a1.Name = a2.Name)
GROUP BY a1.Name,a1.Sales
ORDER BY a1.Sales DESC,a1.Name DESC
) as tab WHERE tab.sales_rank=(select (count(*)+1) div 2 from total_sales);