自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL條件語句實例

數(shù)據(jù)庫 SQL Server
下面為您舉例說明SQL條件語句的用法,供您參考。SQL條件語句是SQL語句中最常見的語句,如果您對SQL語句感興趣的話,不妨一看。

在SQL語句中,SQL條件語句無疑是使用最廣,最常見的SQL語句之一,下面就將為您介紹幾個使用SQL條件語句,供您學習參考。

----查詢StudentMarks 最大的前三條記錄

select  top 3 StudentID,StudentName,Mark from StudentMarks order by Mark desc

----查詢StudentMarks 的第30~40條記錄

1、從前30條的后面, 取前10條

select top 10 * from StudentMarks where StudentID not in(select top 30 StudentID from StudentMarks)

2、先正序取40條, 再反序取10條

select top 10* from (select top 40* from StudentMarks order by Mark ) a
order by Mark desc

3、、利用臨時表
select top 40 * into #Stm from StudentMarks order by Mark

select top * from #Stm  order by Mark desc

----查詢和London同屬于一個國家的城市的客戶
select distinct * from customers where country in
( select country from customers where city='London')

----查詢和London,Paris同屬于一個國家的城市的客戶
select * from customers where country in
(select country from Customers where City in ('London','Paris'))

----查詢單價大于Dofu的產品名
select ProductName from Products where UnitPrice>
(select UnitPrice from Products where ProductName='Tofu')

 

 

 

【編輯推薦】
SQL整體更新的方法

逐條更新數(shù)據(jù)的SQL語句寫法

教您如何進行SQL跨表更新

SQL中IS NULL的語法

SQL中if語句的用法示例

責任編輯:段燃 來源: 博客園
相關推薦

2010-09-26 10:08:43

sql條件語句

2010-09-13 17:11:42

sql server

2010-10-21 14:27:35

SQL Server時

2010-09-09 16:34:19

SQL循環(huán)while

2010-09-25 16:42:45

sql語句

2010-09-07 14:56:49

SQL語句CASE WHEN

2010-09-10 14:33:32

SQL循環(huán)語句

2010-09-03 14:56:12

SQLSELECT語句

2010-09-07 10:56:58

SQL語句

2011-08-18 14:25:26

OracleEXPLAIN PLA

2010-11-18 12:58:25

Oracle條件分支語

2010-07-16 08:47:53

Perl if語句

2024-10-05 00:00:10

SQL語句指定連接條

2010-10-22 11:47:30

sql server存

2009-09-15 09:45:23

Linq動態(tài)條件

2010-05-18 09:02:55

MySQL條件查詢

2010-11-24 17:36:02

MySQL條件查詢語句

2022-07-04 08:51:43

條件語句JavaScript

2021-07-21 10:18:21

Python條件語句Python基礎

2023-06-11 17:25:13

Rust條件語句
點贊
收藏

51CTO技術棧公眾號