The document contains SQL queries that select, group, filter, and order data from various database tables like EMPLEADO, DEPARTAMENTO, and others. The queries retrieve fields like NOMBRE, SUELDO, CARGO, DENOMINACION, and perform operations like counting, summing, finding distinct values, and ordering results.
The document contains SQL queries that select, group, filter, and order data from various database tables like EMPLEADO, DEPARTAMENTO, and others. The queries retrieve fields like NOMBRE, SUELDO, CARGO, DENOMINACION, and perform operations like counting, summing, finding distinct values, and ordering results.
The document contains SQL queries that select, group, filter, and order data from various database tables like EMPLEADO, DEPARTAMENTO, and others. The queries retrieve fields like NOMBRE, SUELDO, CARGO, DENOMINACION, and perform operations like counting, summing, finding distinct values, and ordering results.
SELECT DENOMINACION FROM DEPARTAMENTO ORDER BY LOCALIDAD;
SELECT DENOMINACION FROM DEPARTAMENTO ORDER BY LOCALIDAD DESC;
SELECT SUELDO,COMISION FROM EMPLEADO WHERE ID_DPTO=30;
SELECT NOMBRE FROM EMPLEADO WHERE COMISION>SUELDO/2;
SELECT NOMBRE FROM EMPLEADO WHERE COMISION <= SUELDO*0.25;
SELECT * FROM EMPLEADO ORDER BY ID_DPTO ,ID_EMPLEADO DESC;
SELECT COUNT(*) FROM EMPLEADO;
SELECT ID_DPTO,SUM(SUELDO) FROM EMPLEADO GROUP BY ID_DPTO;
Si fuera por el MONTO TOTAL
SELECT tipo_inmueble as 'codigo_tipo', SUM(PrecioXpza) AS Total FROM dbo.Orden GROUP BY tipo_inmueble;
Si fuera por PRODUCTO
SELECT tipo_inmueble as 'codigo_tipo', tipo_inmueble as 'codigo_tipo', SUM(PrecioXpza) AS Total FROM dbo.Orden GROUP BY tipo_inmueble, tipo_inmueble
select pp.FirstName, sum(SalesQuota) as total_vendido, year(QuotaDate) as año from
Sales.SalesPersonQuotaHistory qh inner join Person.Person pp on qh.BusinessEntityID = pp.BusinessEntityID group by pp.BusinessEntityID, year(QuotaDate), pp.FirstName order by pp.BusinessEntityID;
select pp.ProductID, pp.Name,pp.ProductNumber, pp.ListPrice, count(ss.ProductID) as
veces_vendido from Production.Product pp inner join Sales.SalesOrderDetail ss on pp.ProductID = ss.ProductID group by ss.ProductID, pp.Name, pp.ProductID,pp.ProductNumber, pp.ListPrice order by count(ss.ProductID) desc;
select st.Name, sum(so.OrderQty * so.UnitPrice) as total_vendido from
Sales.SalesOrderHeader sh inner join Sales.SalesOrderDetail so on sh.SalesOrderID = so.SalesOrderID inner join Sales.SalesTerritory st on st.TerritoryID = sh.TerritoryID group by st.TerritoryID, st.Name order by sum(so.OrderQty * so.UnitPrice) desc;