我想查詢平均成績大于60的學生ID和平均成績
select StID,avg(Score)as AvgScore from niu_SC
group by StID
having avg(Score)>60
查詢結果如上圖, 有6位小數, 怎么只顯示2位小數呢? 在SQL語句中怎么寫?
問題補充:Score是decimal類型
最佳答案:
以下為引用的內容: 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
上一篇 從草根站長到建站高手的路線