This document is titled "Transact 2" and contains examples of Transact-SQL queries using functions like SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, AVG, COUNT, SUM on tables like Products, Suppliers, Orders, Employees, Order Details to retrieve and aggregate data. It was submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a database course at Centro de Gestión de Mercados, Logística y Tecnología de la Información in Bogotá, Colombia in August 2010.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document is titled "Transact 2" and contains examples of Transact-SQL queries using functions like SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, AVG, COUNT, SUM on tables like Products, Suppliers, Orders, Employees, Order Details to retrieve and aggregate data. It was submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a database course at Centro de Gestión de Mercados, Logística y Tecnología de la Información in Bogotá, Colombia in August 2010.
This document is titled "Transact 2" and contains examples of Transact-SQL queries using functions like SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, AVG, COUNT, SUM on tables like Products, Suppliers, Orders, Employees, Order Details to retrieve and aggregate data. It was submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a database course at Centro de Gestión de Mercados, Logística y Tecnología de la Información in Bogotá, Colombia in August 2010.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document is titled "Transact 2" and contains examples of Transact-SQL queries using functions like SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, AVG, COUNT, SUM on tables like Products, Suppliers, Orders, Employees, Order Details to retrieve and aggregate data. It was submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a database course at Centro de Gestión de Mercados, Logística y Tecnología de la Información in Bogotá, Colombia in August 2010.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
CENTRO DE GESTIÓN DE MERCADOS, LOGÍSTICA Y TECNOLOGÍA DE
LA INFORMACIÓN BASE DE DATOS AGOSTO DE 2010 BOGOTÁ D.C. EL LENGUAJE TRANSACT-SQL 2
IBETH ASTRID CÁRDENAS PEÑARETE
40130
PRESENTADO A:
SANDRA RUEDA
TRANSACT 2
CENTRO DE GESTIÓN DE MERCADOS, LOGÍSTICA Y TECNOLOGÍA DE
LA INFORMACIÓN BASE DE DATOS AGOSTO DE 2010 BOGOTÁ D.C. select CompanyName,AVG (UnitPrice) from Products P Inner join Suppliers S on P.SupplierId=S.SupplierId group by CompanyName
select AVG ((UnitPrice* Quantity)- Discount)as promedio, SUM ((UnitPrice* Quantity)-
Discount) as total from [Order Details] d Inner join dbo.Orders o on d.OrderID = o.OrderID where MONTH(OrderDate) between 01 and 06 and YEAR (OrderDate) = 1997
select CompanyName,AVG (UnitPrice)
from Products P Inner join Suppliers S on P.SupplierId=S.SupplierId group by CompanyName
select LastName , FirstName , SUM (Freight)
from [Employees] d Inner join dbo.Orders o on d.EmployeeID = o.EmployeeID where (FirstName)like 'Nancy' and (LastName) like 'Davolio' group by LastName,FirstName
select top 1 Min(OrderDate) AS [primer pedido]
from Orders
select count(OrderID) as total
from [Order Details] HAVING SUM ((UnitPrice* Quantity)- Discount) > 2500
select LastName , FirstName , COUNT (s.EmployeeID) as [cantidad de pedidos]
from Employees P Inner join dbo.Orders S on P.EmployeeID=S.EmployeeID group by LastName , FirstName order by [cantidad de pedidos]
select p.EmployeeID, LastName , FirstName , CustomerID, SUM (Freight)
from Employees P Inner join dbo.Orders S on P.EmployeeID=S.EmployeeID group by p.EmployeeID, LastName , FirstName, CustomerID order by CustomerID
select p.EmployeeID, LastName,FirstName, AVG (Freight) as promedio,SUM
((UnitPrice* Quantity)- Discount) as total from (Employees P Inner join dbo.Orders S on P.EmployeeID=S.EmployeeID) Inner Join [Order Details] f on f.OrderID = s.OrderID group by p.EmployeeID, LastName,FirstName having SUM ((UnitPrice* Quantity)- Discount) > 30000