SQL

  • Upload
    leo-ley

  • View
    213

  • Download
    0

Embed Size (px)

DESCRIPTION

Consultas buenasSQL

Citation preview

select UPPER(LEFT(MOREXDE_SEGURO,1)) PrimeraLetra from morexde; OBTIENE LA PRIMERA LETRA Y LO TRANSFORMA A MAYUSselect * from morexde;select SUBSTRING(MOREXDE_NRO_FICHA,2,2) from morexde; OBTIENE UN RANGO DE UNA CADENAselect COUNT(*) from morexde;select COUNT(distinct MOREXDE_LUGAR) from morexde; DEVUELVE EL NRO DE FILAS DE ESA COLUMNA SIN VALORES REPETIDOSCreacion de THidDim_Paciente int not null references Dim_Paciente(idDim_Paciente),idDim_Tiempo int not null references Dim_Tiempo(idDim_Tiempo),idDim_TipoExamen int not null references Dim_TipoExamen(idDim_TipoExamen),idDim_Puesto int not null references Dim_Puesto(idDim_Puesto),idDim_Cliente int not null references Dim_Cliente(idDim_Cliente),idDim_Triaje int not null references Dim_Triaje(idDim_Triaje),idDim_Compania int not null references Dim_Compania(idDim_Compania),cantidad int ,constraint [PK_t_atenciones]primary key nonclustered([idDim_Paciente],[idDim_Tiempo],[idDim_TipoExamen],[idDim_Puesto],[idDim_Cliente],[idDim_Triaje],[idDim_Compania]))Fechaselect distinct extract(year from FechaPedido) as anio,extract(month from FechaPedido) as mes,monthname(FechaPedido) as nombre_mes,extract(quarter from FechaPedido) trimestre,if(extract(month from FechaPedido )>6,2,1) semestrefrom pedidos;select distinct extract(year from FechaPedido) as anio,extract(month from FechaPedido) as mes,monthname(FechaPedido) as nombre_mes,extract(quarter from FechaPedido) trimestre,if(extract(month from FechaPedido )>6,2,1) semestrefrom pedidos;