我想查詢平均成績(jī)大于60的學(xué)生ID和平均成績(jī)
select StID,avg(Score)as AvgScore from niu_SC
group by StID
having avg(Score)>60
查詢結(jié)果如上圖, 有6位小數(shù), 怎么只顯示2位小數(shù)呢? 在SQL語(yǔ)句中怎么寫?
問(wèn)題補(bǔ)充:Score是decimal類型
最佳答案:
以下為引用的內(nèi)容: Create table Testtable2(ID int identity(1,1),score float,)goinsert into Testtable2(score)select 86.1union allselect 75.1union allselect 69.4select avg(score) as avescore,cast(avg(score) as decimal(10,2)) as ExactAveScore from Testtable2 |
avescore ExactAveScore
76.8666666666667 76.87