SQL where条件判断同一列中相同的数据
作者:我就是个世界
发表于:2009-01-16
比如:交易信息表中有一列(卡号cardID)和(交易金额money),我想比较某一时间内交易金额最高的卡号,那么where后判断cardID列相同的卡号,则判断语句如下:
[code]select top 1 cardID,sum(money)
from 交易信息表
where 时间 between .. and ..
group by cardID
order by sum(money) desc [/code]
[code]select top 1 cardID,sum(money)
from 交易信息表
where 时间 between .. and ..
group by cardID
order by sum(money) desc [/code]
请发表您的评论