-
select...(用逗號(hào)隔開)from... select * from *表示所有的列 select Top 100 * from 所有列的前100行 oder by desc倒序 asc正序 oder by...desc 可以同時(shí)按照多個(gè)column排列 oder by 2 按照選擇的第二個(gè)排列 isnull函數(shù) isnull(color,'')用空格代替空值NULL as關(guān)鍵字:給表列起名 +關(guān)鍵字:連接“列”和“字符串” 注意‘’中的空格 算術(shù)表達(dá)式 + - * / select rate*40*52 as...from... round(rate*40*52,1) 1表示保留小數(shù)點(diǎn)后1位 0則不保留查看全部
-
table中的各種屬性說明查看全部
-
兩種時(shí)間格式,后面月日年 between and >= 和 < :不包含某一天查看全部
-
order by 2:select屬性列表中的第二個(gè)屬性 isnull(Color,'') as Color: 用空格代替空值 'The list price for ' + ProductNumber + ' is $ ' + convert(varchar, ListPrice) + '.' as [Description]查看全部
-
isnull(color,"")查看全部
-
記憶名詞查看全部
-
講的很好的,為什么后面沒有更新了?查看全部
-
聲音杠杠的查看全部
-
聲音好聽查看全部
-
啥時(shí)候出新的啊查看全部
-
記住這些名詞的意思 以后幫助很大查看全部
-
重新學(xué)習(xí)數(shù)據(jù)庫~查看全部
-
--count:統(tǒng)計(jì)結(jié)果數(shù) select count(SalesPersonID) from Sales.SalesOrderHeader where SalesPersonID is not null --distinct:獨(dú)一無二的 select distinct(SalesPersonID) from Sales.SalesOrderHeader where SalesPersonID is not null select SalesPersonID,OrderDate,Max(TotalDue) as MaximumTotalSales from [Sales].[SalesOrderHeader] where SalesPersonID is not null and OrderDate >='2007/1/1' group by SalesPersonID,OrderDate having Max(TotalDue)>150000 order by OrderDate desc Having與Where的區(qū)別 where 子句的作用是在對(duì)查詢結(jié)果進(jìn)行分組前,將不符合where條件的行去掉,即在分組之前過濾數(shù)據(jù),where條件中不能包含聚組函數(shù),使用where條件過濾出特定的行。 having 子句的作用是篩選滿足條件的組,即在分組之后過濾數(shù)據(jù),條件中經(jīng)常包含聚組函數(shù),使用having 條件過濾出特定的組,也可以使用多個(gè)分組標(biāo)準(zhǔn)進(jìn)行分組查看全部
-
在什么之間:between ... and ... 例: select SalesOrderID,OrderDate,SalesPersonID,TotalDue as TotalSales from Sales.SalesOrderHeader where Orderdate between '2005-08-01' and '1/1/2006' --通配符%,模糊搜索 select * from Production.Product where name like '%Mountain%' --通配符_,單個(gè)字符 select * from Production.Product where name like '_ountain%' --in:匹配多個(gè)字段,即集合 select * from Production.Product where color in ('red','white','black') --not in : 不等于某個(gè)字段 select * from Production.Product where class not in ('H','L') --查詢null值 select * from Production.Product where size isnull --查詢非null select * from Production.Product where size is not null查看全部
-
use AdventureWorks--選擇數(shù)據(jù)庫 select Top 10 * from Production.Product--輸出前10個(gè)數(shù)據(jù) --根據(jù)listprice和Name進(jìn)行降序排序 select ProductID, Name, ProductNumber, Color, Size, ListPrice from Production.Product order by listprice desc,Name desc --根據(jù)輸出的第二個(gè)列進(jìn)行排序,即Name select ProductID, Name, ProductNumber, Color, Size, ListPrice from Production.Product order by 2 --isnull:輸出時(shí)代替null值,例: select ProductID, Name, ProductNumber, isnull(Color,''), isnull(Size,''), ListPrice from Production.Product --as:別名 select ProductID, Name, ProductNumber, isnull(Color,'') as Color, isnull(Size,'') as Size123, --using an alias ListPrice from Production.Product --使用”+“連接字符 select ProductID, Name as ProductName, 'The list price for '+ProductNumber+'is $ '+convert(varchar,ListPrice)+'.' as Description from Production.Product --算術(shù)計(jì)算,round(rate*40*52,1),1代表保留一位小數(shù),0則不保留 select BusinessEntityID, rate*40*52 as AnnualSalary, round(rate*40*52,1) as AnnualSalary round(rate*40*52,0) as AnnualSalary from HumanResources.EmployeePayHistory查看全部
舉報(bào)
0/150
提交
取消