日期:2014-05-18  浏览次数:20461 次

这样一句SQL的意思
有个表salerecord
pname         商品名称
pkinds       商品所属类别id
uname         购买者名称
pcount       购买数量
saledate   出售日期
price         价格
listid       订单号
state         0表示尚没有生成订单,1表示提交尚未结算,2交易完成


请问:mysql   =   "select   top   20   pname,sum(pcount)   as   scount   from   salerecord   where   state <> '0 '   and   saledate> # "   +   DateTime.Now.AddMonths(-1).ToString   +   "#   group   by   pname   order   by   sum(pcount)   desc "这句话的意思

帮帮忙!谢谢!

------解决方案--------------------
"select top 20 pname,sum(pcount) as scount from salerecord where state <> '0 ' and saledate> # " + DateTime.Now.AddMonths(-1).ToString + "# group by pname order by sum(pcount) desc "

求 上个月 每种商品卖出的数量 按数量排序 state <> '0 ' 不知道是什么状态
------解决方案--------------------
select top 20 pname,sum(pcount) as scount from salerecord where state <> '0 ' and saledate> # " + DateTime.Now.AddMonths(-1).ToString + "# group by pname order by sum(pcount) desc

按pname 分组,pcount的和降序,取前20个符合条件state不为0并且saledate是上个月以前的pname和pcount和
------解决方案--------------------
查询最近一个月以来销售数量在前20名内的商品名称及数量。
------解决方案--------------------
有个表salerecord
pname 商品名称
pkinds 商品所属类别id
uname 购买者名称
pcount 购买数量
saledate 出售日期
price 价格
listid 订单号
state 0表示尚没有生成订单,1表示提交尚未结算,2交易完成


请问:mysql = "select top 20 pname,sum(pcount) as scount from salerecord where state <> '0 ' and saledate> # " + DateTime.Now.AddMonths(-1).ToString + "# group by pname order by sum(pcount) desc "这句话的意思

-----------
不好意思 上个贴没看你的

出售日期 大于上个月 每种商品 未结算和交易完成的购买总数量  按商品总数量排序