USE jugos_ventas;
-- Funciones con String
SELECT LTRIM(" MySQL is Easy");
SELECT RTRIM("MySQL is Easy ");
SELECT TRIM(" MySQL is Easy ");
SELECT CONCAT("MySQL is Easy ","aún no lo crees?");
SELECT UPPER("mysql is a database");
SELECT LOWER("MYSQL IS A DATABASE");
SELECT SUBSTR("mysql es una base interesante",14,4);
SELECT CONCAT(NOMBRE," ", DNI) FROM tabla_de_clientes;
-- Funcions con Fehas
SELECT CURDATE();
SELECT CURRENT_TIMESTAMP();
SELECT YEAR(CURRENT_TIMESTAMP());
SELECT MONTH(CURRENT_TIMESTAMP());
SELECT DAY(CURRENT_TIMESTAMP());
SELECT MONTHNAME(CURRENT_TIMESTAMP());
SELECT DAYNAME(CURRENT_TIMESTAMP());
SELECT DATEDIFF(CURRENT_TIMESTAMP(),"1980-06-14") AS DIAS_DE_DIFERENCIA;
SELECT CURRENT_TIMESTAMP() AS DIA_HOY, DATE_SUB(CURRENT_TIMESTAMP(),INTERVAL 1 MONTH) AS RESULT;
SELECT DISTINCT
FECHA_VENTA,
DAYNAME(FECHA_VENTA) AS DIA,
MONTHNAME(FECHA_VENTA) AS MES,
YEAR(FECHA_VENTA) AS AÑO
FROM facturas;
-- Funciones Numericas
SELECT (34 + 346 - 67) / 15 * 29 AS RESULT;
SELECT CEILING(23.1222);
SELECT FLOOR(23.9999);
SELECT RAND() AS RESULT;
SELECT ROUND(254.545,2);
SELECT ROUND(254.545,1);
SELECT
NUMERO, CANTIDAD, PRECIO, ROUND(CANTIDAD * PRECIO,2) AS FACTURACION
FROM items_facturas;
-- Funciones Convertir formato
SELECT CURRENT_TIMESTAMP() AS RESULTADO;
SELECT CONCAT("La fecha de y la hora de hoy SON: ", CURRENT_TIMESTAMP()) as RESULTADO;
SELECT CONCAT("La fecha y el horario son: ",DATE_FORMAT(CURRENT_TIMESTAMP(),"%W, %d/%m/%Y a las %T")) AS RESULTADO;
SELECT CONVERT(23.45, CHAR) AS RESULT;
SELECT SUBSTR(CONVERT(23.45, CHAR),3,1) AS RESULT;