⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 数据分组与汇总.sql

📁 简单的sql语句 数据与汇总。 高手多多指点。
💻 SQL
字号:
use northwind
select * from orders
select top 220 with ties orderid,employeeid,customerid from orders     
order by employeeid 
select * from employees
select count(*) from employees
select * from products
select count(*) from products
select count(productname) from products

select 
'num productid'=count(*),
'max supplierid'=max(supplierid),
'min supplierid'=min(supplierid),
'avg unitprice'=avg(unitprice)
from products

select unitprice from products

select 
count(*) as 'num productid',
max(supplierid) as 'max supplierid',
min(supplierid) as 'min supplierid',
avg(unitprice) as 'avg unitprice' 
from products

select * from [Order Details]USE Northwind

SELECT OrderID AS ProdID,SUM(Quantity)AS AmountSold
FROM [Order Details] 
where OrderID in(10248,10249,10251,10255)
GROUP BY OrderIDs

select * from [Order Details]

select orderid,sum(quantity)as [sum quantity] from  [Order Details]
group by orderid
having orderid in(10248,10249,10250) and sum(quantity)>27

select * from [Order Details]
where orderid in (11077,11076)
order by orderid,productid

select productid,sum(quantity) as total from [Order Details]
group by productid
having sum(quantity)>1100

select orderid,quantity,sum(unitprice)as total from [Order Details]
where orderid in (11077,11076)
group by orderid,quantity
with rollup
order by orderid,quantity

select orderid,quantity,sum(unitprice)as total from [Order Details]
where orderid in (11077,11076)
group by orderid,quantity
with cube
order by orderid,quantity

select orderid,quantity,unitprice from [Order Details]
where orderid in (11077,11076)
order by orderid,quantity
compute sum(unitprice) by  orderid








  

⌨️ 快捷键说明

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