Entrada destacada

Freddie Armando Romero Paredes Plans

Freddie Armando Romero Plans Leer más publicaciones en Calaméo

domingo, 27 de noviembre de 2022

Select DBeaver

 select customerid

from 

customers 


select cast(customerid as varchar) as customerid_text

from

customers 


select convert(varchar, customerid) as customerid_text

from

customers 


--CONCATENACION--


select concat(customerid,'', customername, '', contactname)

from 

customers


--FUNCIONES DE CADENAS--


--SUBSTRING--


select substring('Microsoft SQL Server', 11, 3) as result;


select customername, substring(customername, 5, 4) as recorte

from

customers


--LEFT Y RIGHT--


select left('Microsoft SQL Server', 9) as result;

select right('Microsoft SQL Server', 6) as result;


select customername, left(customername, 2) as recorte_izq

from

customers


--LENGTH Y DATALENGTH--


select length('Microsoft SQL Server') as result; --En sql server se usa la función length--

select datalength('Microsoft SQL Server') as result; --En sql server se usa la función datalength--


select customername, length(customername) as cantidad_caracteres

from

customers


--CHARINDEX--


select strpos('Microsoft SQL Server', 'SQL') as result; --En sql server se usa la función charindex--


select customername, strpos(customername, 'Imp') as posicion

from

customers


--REPLACE--

select replace('Microsoft SQL Server Hekaton', 'Hekaton', '2014 In-Memory OLTP Engine') as result;


select customername, replace(customername, '', '***') as reemplazo

from

customers


--UPPER Y LOWER--


select upper('Microsoft SQL Server') as up, lower('Microsoft SQL Server') as low;


select customername, upper(customername) as mayuscula, lower(customername) as minuscula

from

customers 


--Predicado Like--


select customername

from

customers 

where 

customername like 'C%' --Búsqueda por la letra que empieza el texto--


select customername 

from 

customers 

where 

customername like '%a' --Búsqueda por la letra que termina el texto--


select customername

from

customers 

where 

upper(customername) like '%A%' --Búsqueda por la letra que contenga el texto (al inicio, al final, al medio)--


--FECHA Y HORA--


--GETDATE--


select now() --En sql server se usa la función getdate--


--GETUTCDATE--


select now() at time zone 'utc' --En sql server se usa la función GETUTCDATE--


--current timestamp--


select current_timestamp 


--current date--


select current_date 


--vista completa--


select now(), now() at time zone 'utc', current_timestamp, current_date


--CONVERSION DATOS TIPO FECHA Y HORA--


select *

from public.pg4e_meta

No hay comentarios:

Publicar un comentario