- 情感问答
- 答案列表
sql 查询最大值:sql查询最大值记录[朗读]
selecttop1fromtempletgroupbyt_nameorderbymax(t_num)havingmax(t_num);试一下!~。
selectt1.*from表名ast1,(select编号,max(状态码)as最大状态码from表名groupby编号)ast2wheret1.编号=t2.编号andt1.状态码=t2.最大状态码这样看看。
用max函数返回一列中的最大值.null值不包括在计算中.selectmax(column_name)fromtable_name
selectsno,cnofromscorewheredegree=(selectmax(degree)fromscore)或者selecttop1sno,cnofromscoreorderbydegreedesc
declare@maxdecimal(10,4)select@max=max(saleprice)fromtblorderdetailwhile(@max<100)beginupdatetblorderdetailsetsaleprice=saleprice+saleprice/10select@max=max(saleprice)fromtblorderdetailendselect@max