子查询.sql

来自「简单的sql语句 数据与汇总。 高手多多指点。」· SQL 代码 · 共 47 行

SQL
47
字号
use northwind
go
 
select * from orders
go

select T.orderid,T.customerid
from(select orderid,customerid
     from orders) as T
go

select orderid,customerid from orders
go


select * from orders
go

select * from [order details]
where productid=23
go

select customerid from orders
where 20 >( select quantity from [order details]
                 where productid=23 and orders.orderid=[order details].orderid
                )
go

select * from [order details]
go

select productid,quantity from [order details] as or1
where quantity = (select max(quantity) from [order details] as or2
                   where or1.productid=or2.productid
                  )
order by productid
go

/*
select productid,max(quantity)as quantity from [order details]
group by productid
order by productid
go
与上面代码等价。哈哈哈哈
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?