日期:2014-05-16 浏览次数:20476 次
SELECT Prizes_pids,Prizes_Total FROM LotteryPrizesName ORDER BY Prizes_pids ASC
编号 总数
Prizes_pids Prizes_Total
1 8
2 16
3 20
4 40
SELECT a.jiangpin_no,COUNT(a.jiangpin_no)sum FROM Lottery a ,LotteryPrizesName b WHERE a.jiangpin_no=b.Prizes_No GROUP BY jiangpin_no
jiangpin_no sum
1 1
3 1
4 15
update LotteryPrizesName
set Prizes_Surplus=Prizes_Total-ss
from
(
SELECT a.jiangpin_no,COUNT(a.jiangpin_no) ss
FROM Lottery a ,LotteryPrizesName b
WHERE a.jiangpin_no=b.Prizes_No
GROUP BY jiangpin_no
)b
where b.jiangpin_no = LotteryPrizesName.Prizes_pids