久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

SQL Server中Insert與Select的組合使用

瀏覽:155日期:2023-11-04 08:46:42

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.Discountfrom Orders o,[Order Details] od, Employees e,Products p, Suppliers s, Customers cwhere (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

標簽: Sql Server 數據庫
主站蜘蛛池模板: 昂仁县| 芮城县| 武强县| 高邮市| 佛坪县| 北宁市| 乌拉特中旗| 南充市| 杨浦区| 和林格尔县| 江西省| 越西县| 太和县| 庄浪县| 福鼎市| 瓮安县| 左云县| 广水市| 屏东县| 通化县| 淮北市| 章丘市| 湟源县| 盘山县| 盐山县| 东阿县| 当阳市| 眉山市| 偃师市| 英德市| 庆云县| 孟州市| 依兰县| 呼伦贝尔市| 伊春市| 葵青区| 连山| 怀集县| 南京市| 宜君县| 奉节县|