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

SQL查詢最大最小值的示例

數(shù)據(jù)庫(kù) SQL Server
下面以實(shí)例的形式為您介紹SQL查詢最大最小值的實(shí)現(xiàn)方法,供您參考,希望對(duì)您學(xué)習(xí)SQL查詢方面能夠有些許幫助。

下面這個(gè)SQL查詢***最小值的例子使用了Northwind數(shù)據(jù)庫(kù),取出每種書目中價(jià)格最貴的3本書,希望可以讓您對(duì)SQL查詢有更多的認(rèn)識(shí)。

  1. declare @Category table   
  2. (   
  3. id int identity(1,1) not null,   
  4. CategoryId int,   
  5. CategoryName varchar(50)   
  6. )   
  7. declare @MostExpensive table   
  8. (   
  9. ProductName varchar(50)   
  10. )   
  11. declare @counter int,@number int   
  12. set @counter=0   
  13. insert @Category select CategoryId,CategoryName from Categories   
  14. select @number=count(*) from @Category   
  15. while @counter<@number   
  16. begin   
  17. set @counter=@counter+1   
  18. insert @MostExpensive select top 3 ProductName from products where categoryid=(select CategoryId from @Category where id=@counter) order by UnitPrice desc   
  19. end   
  20. select * from @MostExpensive  

 

 

【編輯推薦】

SQL查詢***值最小值問題

如何給SQL查詢添加合計(jì)行

SQL查詢效率的討論

SQL查詢時(shí)間段的語句寫法

SQL查詢?nèi)掌诘膯栴}

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-09-26 15:56:59

SQL查詢

2009-09-17 09:50:34

數(shù)組

2019-01-08 15:11:50

最大值最小值算法

2010-11-24 16:42:40

mysql命令行求最小

2021-05-09 22:41:43

Python數(shù)據(jù)統(tǒng)計(jì)

2020-10-13 08:53:04

算法最小值

2010-05-27 14:27:30

MySQL全文索引

2017-07-03 10:52:20

深度學(xué)習(xí)人工智能

2010-09-25 16:37:33

SQL動(dòng)態(tài)查詢

2010-10-12 14:27:57

mysql全文索引

2021-04-23 09:58:28

O(1)序列

2022-09-26 12:17:14

clamp() 函數(shù)CSS

2010-09-10 13:56:25

SQLMAX()函數(shù)

2010-11-24 11:52:15

MYSQL表字段最大值

2010-09-26 14:21:43

sql跨服務(wù)器查詢

2010-11-09 09:43:20

SQL Server查

2021-04-29 10:01:30

JavaMathJava編程

2016-09-21 21:22:11

Javascript前端數(shù)學(xué)

2024-04-18 08:51:10

原碼反碼補(bǔ)碼

2017-09-22 11:01:00

Oracle數(shù)據(jù)庫(kù)中直方圖
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)