【Sql Server】DateBase-简单的Select查询
Select語句查詢
小技巧:select 12*13 as 計算結果
Distinct:消除重復列
?
Where [and/or][多個條件](like ‘河南%’)
Where 字句運算符
?????? Between and
?????? X%10=0
?????? In(80,90,95)
?????? Not in (80.90.100)
?
排序Order by ASC(低——高)DESC(高——低)
?
分組
select 課程編號,AVG(分數) f
rom 成績信息
where 考試編號=‘01’
group by 課程編號
rollup :按第一個關鍵字小計,再總結
cube :按次關鍵字小計
多個關鍵字一層一層排序
?
使用函數
select Max(分數)from 成績信息 where 考試編號= ‘01’
select Min(分數)from 成績信息 where 考試編號= ‘01’
select Avg(分數) from 成績信息 where 考試編號= ‘01’
select Sum(分數) from 成績信息 where 考試編號= ‘01’
top 3(分數) from 成績信息where 考試編號= ‘01’
?
having Avg(分數) >=90 聚合結果
order by 考試編號
?
插入數據insert into 表(列) value()
??????? 【全部插入|部分插入】
Insert (select語句)——新建數據表
Select??into 臨時表|新建數據表 from。。。where。。。
?
update [top] 表名/視圖
set? 新的內容
where
?
update目標內容
set 新的內容
from 多表鏈接 on
where
?
Delete?內容from 表名 where? 條件
?
Top關鍵字/Top表達式[Select /update/delete/insert]
Top (數值/百分比)/利用變量
With ties 同等內容包含進來
?
?
?
Compute 字句 查詢結果合計
Compute
{
{Avg|count|Max|Min|Stdev|stdevp|var|varplsum}
}
Compute 函數(列)
By XX[中斷合計]
總結
以上是生活随笔為你收集整理的【Sql Server】DateBase-简单的Select查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Sql Server】DateBase
- 下一篇: 【Sql Server】DateBase