高手帮忙解释一下这句SQL语句
select sum(tal) from (select price*pcount as tal from salerecord where uname= ' " + session( "username ") + " ' and state= '0 ' order by id desc)
帮忙解释一下,谢谢!
------解决方案--------------------select sum(tal) from (select price*pcount as tal from salerecord where uname= ' " + session( "username ") + " ' and state= '0 ' order by id desc)
price是单价?? pcount是买东西的数量?
如果是这样的话应该就是返回的一个名字为username,state=0的用户购买所有东西所花的钱吧?state不知道什么意思,所以原封不动的搬过来。
有点不明白,括号里面的 order by id desc这个按id排序的有什么左右???被外面sum(tal)不是排不排序都一样了么??