国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 资溪县| 故城县| 连江县| 体育| 广饶县| 昔阳县| 永城市| 永顺县| 莎车县| 涡阳县| 龙山县| 新丰县| 广德县| 玉环县| 滦南县| 正蓝旗| 和田县| 惠州市| 柞水县| 永登县| 长春市| 乐业县| 辽源市| 天台县| 鹤壁市| 汉阴县| 万全县| 庆云县| 湖南省| 陆川县| 尉氏县| 邹城市| 八宿县| 拜城县| 阆中市| 淮北市| 南安市| 丰顺县| 崇左市| 新化县| 桑日县|