国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

SQL Server中Insert與Select的組合使用

2024-08-31 00:52:15
字體:
來源:轉載
供稿:網友

SQL Server中有示例數據庫Northwind。新建表Sales用于存儲銷售信息,字段為EmployeeID,PRoductID,SupplierID,CustomerID,OrderDate,UnitPrice,Total,Quantity,Discount。

下面的語句從Orders,Order Details, Employees,Products, Suppliers, Customers表選擇相應的

數據插入Sales表:

insert into Sales(EmployeeID,ProductID,SupplierID,CustomerID,
OrderDate,UnitPrice,Total,Quantity,Discount)
select e.EmployeeID, p.ProductID, s.SupplierID,
c.CustomerID, o.OrderDate, od.UnitPrice,
od.Quantity*od.UnitPrice*(1.0-od.Discount)Total,
Od.Quantity, od.Discount
from Orders o,[Order Details] od, Employees e,
Products p, Suppliers s, Customers c
where (o.OrderID = od.OrderID) and
(o.EmployeeID = e.EmployeeID) and
(o.CustomerID = c.CustomerID) and
(od.ProductId = p.ProductID) and
(p.SupplierID = s.SupplierID);
go


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 项城市| 九江市| 铜鼓县| 台中县| 东乡| 崇左市| 合肥市| 正安县| 安化县| 平塘县| 邹平县| 兴义市| 陵川县| 华宁县| 铅山县| 富川| 怀安县| 台安县| 台山市| 西宁市| 读书| 乳山市| 兴安县| 西充县| 九江县| 嘉禾县| 鸡西市| 丰宁| 温宿县| 德阳市| 罗城| 克东县| 循化| 开远市| 平利县| 高淳县| 和硕县| 贵阳市| 广昌县| 迁西县| 堆龙德庆县|