You are on page 1of 3

11/04/2015

select *
from DimProduct

select ProductKey,EnglishProductName,StartDate
from DimProduct

select ProductKey,EnglishProductName,StartDate
from DimProduct
where EnglishProductName like 'h%'

select ProductKey,EnglishProductName,StartDate
from DimProduct
where EnglishProductName like 'c%'

select ProductKey,EnglishProductName,StartDate
from DimProduct
where datepart(yy,StartDate)=1998 and datepart(mm,StartDate)=6

select ProductKey,EnglishProductName,StartDate
from DimProduct
where datepart(yy,StartDate)=1998 and datepart(mm,StartDate)=6 and
EnglishProductName like 's%'

18/04/2015
select ProductKey,SpanishProductName,ListPrice
from DimProduct

select ProductKey,SpanishProductName,ListPrice
from DimProduct
where ListPrice between 300 and 310

selectProductKey,SpanishProductName,ListPrice,
Preciodeventa=(ListPrice+(0.3*ListPrice))
from DimProduct

O
PARA AGREGAR UNA FILA MAS:
selectProductKey,SpanishProductName,ListPrice,
(ListPrice+(0.3*ListPrice))as ‘Preciodeventa’
from DimProduct

select ProductKey,SpanishProductName,ListPrice,
Preciodeventa=(ListPrice+(0.3*ListPrice))
from DimProduct
where (ListPrice+(0.3*ListPrice)) between 200 and 210

PARA HALLAR FECHAS DE DOS MANERAS CON DATEPART Y OTRO CON INTERVALOS:

select ProductKey,SpanishProductName,StartDate,ListPrice,
Preciodeventa=(ListPrice+(0.3*ListPrice))
from DimProduct
where datepart (mm,StartDate)between 7 and 8 and
datepart(yy,StartDate)=2005
select ProductKey,SpanishProductName,StartDate,ListPrice,
Preciodeventa=(ListPrice+(0.3*ListPrice))
from DimProduct
where StartDate between '01/07/2005' and '30/08/2015'

PARA HACER CONSULTAS DE 2 TABLA

select dp.ProductKey,dp.SpanishProductName,fp.UnitCost
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey

PARA HACER CONSULTAS DE 3 TABLA

select dp.ProductKey,dp.SpanishProductName,fp.UnitCost,dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey

EJERCICIOS
select dp.EnglishProductName,fp.UnitCost
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost))
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost)),dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost)),dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey
where SpanishDayNameOfWeek='Viernes' and (fp.UnitCost+(0.3*fp.UnitCost))>900

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost)),dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey
where SpanishDayNameOfWeek='Jueves' and (fp.UnitCost+(0.3*fp.UnitCost))>1400
ORDENAR EN FORMA DESCENDENTE

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost)),dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey
where SpanishDayNameOfWeek='Viernes' and (fp.UnitCost+(0.3*fp.UnitCost))>900
order by (fp.UnitCost+(0.3*fp.UnitCost)) desc

ORDENAR EN FORMA ASCENDENTE

selectdp.EnglishProductName,fp.UnitCost,
Preciodeventa=(fp.UnitCost+(0.3*fp.UnitCost)),dd.SpanishDayNameOfWeek
from DimProduct dp inner join FactProductInventory fp
on fp.ProductKey=dp.ProductKey inner join DimDate dd
on fp.DateKey=dd.DateKey
where SpanishDayNameOfWeek='Viernes' and (fp.UnitCost+(0.3*fp.UnitCost))<900
order by (fp.UnitCost+(0.3*fp.UnitCost)) asc

You might also like