SQL資料庫資料檢索top和distinct

2021-08-20 18:36:17 字數 298 閱讀 6696

一、distinct:針對查詢的結果去去除重複(主要針對查詢的結果)

top獲取前幾條資料,top一般都與order by連用(desc、asc)

distinct去除重複的資料

select distinct sname from student

select top 5 * from student order by tmath desc

二、查詢前百分之30%,若不是整數比向上取整

select top 35 percent * from tablescore order by desc

SQL資料庫資料檢索top和distinct

一 distinct 針對查詢的結果去去除重複 主要針對查詢的結果 top獲取前幾條資料,top一般都與order by連用 desc asc distinct去除重複的資料 select distinct sname from student select top 5 from student o...

三 SQL 資料檢索 (萬用字元)

如 t employee表中fname欄位匹配如下規則的資料行 以任意字元開頭,剩餘部分為 erry 如 萬用字元表示式 k 匹配以 k 開頭 任意長度的字串 萬用字元表示式 b t 匹配以 b 開頭 以 t 結尾 任意長度的字串 例如 t employee表中fname欄位以 t 開頭長度,長度任...

資料庫和SQL 檢索資料

資料庫相當於乙個檔案管理系統,裡面存放各種檔案 表 每個檔案又含有各種資訊 列 屬性 每個表有至少乙個識別符號 主鍵 它是獨一無二的,儘管刪除了這個條資料 行 再新建行的時候,這個主鍵也不能重新使用。sql 結構化查詢語言 不像人類語言和計算機語言一樣複雜,只是意思簡單明瞭的英語單詞組成的語言,專門...