This document appears to be a report submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a class on Transact-SQL 3. It contains several Transact-SQL queries with inner joins on tables from a database to retrieve and aggregate data. The document provides examples of using functions like COUNT, SUM, AVG, DISTINCT and GROUP BY in T-SQL queries.
This document appears to be a report submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a class on Transact-SQL 3. It contains several Transact-SQL queries with inner joins on tables from a database to retrieve and aggregate data. The document provides examples of using functions like COUNT, SUM, AVG, DISTINCT and GROUP BY in T-SQL queries.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document appears to be a report submitted by Ibeth Astrid Cárdenas Peñarete to Sandra Rueda for a class on Transact-SQL 3. It contains several Transact-SQL queries with inner joins on tables from a database to retrieve and aggregate data. The document provides examples of using functions like COUNT, SUM, AVG, DISTINCT and GROUP BY in T-SQL queries.
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 3
IBETH ASTRID CÁRDENAS PEÑARETE
40130
PRESENTADO A:
SANDRA RUEDA
TRANSACT 3
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 , City , Phone , ProductName , UnitPrice ,UnitsInStock from Suppliers P Inner join Products S on P.SupplierID=S.SupplierID where UnitsInStock<20 order by UnitsInStock
select DISTINCT FirstName , LastName , Title , CustomerID
from (dbo.Employees P Inner join dbo.Orders S on P.EmployeeID=S.EmployeeID) where CustomerID = 'ALFKI'
SELECT DISTINCT CompanyName,OrderDate
FROM dbo.Customers P Inner join dbo.Orders S on P.CustomerID=S.CustomerID WHERE YEAR (OrderDate)= 1996 AND MONTH (OrderDate)= 10 ORDER BY OrderDate
SELECT DISTINCT ProductName , MONTH (OrderDate) AS MES, YEAR (OrderDate)
AS AÑO, SUM (Quantity)AS TOTAL FROM (dbo.Products P Inner join [Order Details] O on P.ProductID=O.ProductID)INNER JOIN dbo.Orders A ON O.OrderID=A.OrderID GROUP BY ProductName ,MONTH (OrderDate) , YEAR (OrderDate) ORDER BY YEAR (OrderDate), MONTH (OrderDate)
SELECT ProductName , UnitPrice , S.CategoryID
FROM dbo.Products P Inner join dbo.Categories S on P.CategoryID=S.CategoryID GROUP BY ProductName , UnitPrice , S.CategoryID HAVING S.CategoryID IN (3,4,5) ORDER BY S.CategoryID
SELECT DISTINCT City
FROM Customers order by City
SELECT CategoryName, COUNT (CategoryName)AS TOTAL
FROM dbo.Categories P Inner join dbo.Products S on P.CategoryID=S.CategoryID GROUP BY CategoryName ORDER BY COUNT (CategoryName)
SELECT CategoryName, avg (UnitPrice)AS TOTAL
FROM dbo.Categories P Inner join dbo.Products S on P.CategoryID=S.CategoryID where CategoryName ='Grains/Cereals' GROUP BY CategoryName
SELECT ContactName , OrderID
FROM dbo.Customers P Inner join dbo.Orders S on P.CustomerID=S.CustomerID WHERE ContactName LIKE 'A%'
SELECT top 50 percent FirstName, LastName , CompanyName ,Freight
FROM (dbo.Employees P Inner join [Orders] O on P.EmployeeID=O.EmployeeID)INNER JOIN dbo.Customers A ON O.CustomerID=A.CustomerID ORDER BY Freight
SELECT QuantityPerUnit , UnitPrice
FROM dbo.Products WHERE QuantityPerUnit LIKE '%bottles%' ORDER BY UnitPrice DESC
SELECT CompanyName , CategoryName
FROM (dbo.Suppliers P Inner join [Products] O on P.SupplierID=O.SupplierID)INNER JOIN dbo.Categories A ON O.CategoryID=A.CategoryID