Mandos de sql Select*= paras seleccionar toda una data Select name from user= para seleccionar una data especifica Select name, age from user= para seleccionar más de una columna Select*from user whereid=,<,>,<=,>=,!= ( para filtrar) SELECT id, age FROM user WHERE age <= 21; ( para filtrar mas de una columna) SELECT id, name FROM user WHERE age > 50 OR height < 185;( para establecer un rango) SELECT id, name FROM user WHERE age < 70 AND age > 13;m ( para establecer un rango asociativo) SELECT vin, brand, model FROM car WHERE production_year NOT BETWEEN 1995 AND 2005;( para establecer otro tipo de rango) SELECT id, name FROM user WHERE age BETWEEN 13 AND 70; ( otra forma de rango) SELECT * FROM user WHERE age NOT BETWEEN 20 AND 30; ( otra forma de rango) SELECT*FROM MOVIE JOIN director on movie.director_id=director.id( para unir datos de dos columnas ) SELECT vin FROM car WHERE (production_year < 1999 OR production_year > 2005) AND (price < 4000 OR price > 10000); ( establecer dos rangos) SELECT movie.id, title, production_year AS produced_in, name, birth_year AS born_in FROM movie JOIN director ON director.id = director_id WHERE (title LIKE '%a%' AND production_year > 2000 ) OR (birth_year between 1945 AND 1995);(ejemplo de comando) SELECT * FROM car WHERE brand = 'Ford';( ubicar un label) SELECT vin, brand, model FROM car WHERE brand LIKE 'F%', '%F', ' %F%' ( para ubicar valores que no sabemos el nombre completo) SELECT * FROM car WHERE brand LIKE 'Volk_wagen'; SELECT * FROM car WHERE price IS NOT NULL; SELECT * FROM car WHERE price IS NULL; SELECT * FROM car WHERE (price * 0.2) > 2000; ( hacer operacion y comparar luego) SELECT movie.title, director.name FROM movie JOIN director ON movie.director_id = director.id; select COUNT (invoiceid) from Invoice= para contar un numero de variables en una columna select MAX (total) from invoice 600810 02 00 SQL Statement Syntax AND / OR SELECT column_name(s) FROM table_name WHERE condition AND|OR condition ALTER TABLE ALTER TABLE table_name ADD column_name datatypeor ALTER TABLE table_name DROP COLUMN column_name AS (alias) SELECT column_name AS column_alias FROM table_nameor SELECT column_name FROM table_name AS table_alias BETWEEN SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2 CREATE DATABASE CREATE DATABASE database_name CREATE TABLE CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, ... ) CREATE INDEX CREATE INDEX index_name ON table_name (column_name)or CREATE UNIQUE INDEX index_name ON table_name (column_name) CREATE VIEW CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition DELETE DELETE FROM table_name WHERE some_column=some_valueor DELETE FROM table_name (Note: Deletes the entire table!!) DELETE * FROM table_name (Note: Deletes the entire table!!) DROP DATABASE DROP DATABASE database_name DROP INDEX DROP INDEX table_name.index_name (SQL Server) DROP INDEX index_name ON table_name (MS Access) DROP INDEX index_name (DB2/Oracle) ALTER TABLE table_name DROP INDEX index_name (MySQL) DROP TABLE DROP TABLE table_name EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?) BEGIN --do what needs to be done if exists END ELSE BEGIN --do what needs to be done if not END GROUP BY SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name HAVING SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name HAVING aggregate_function(column_name) operator value IN SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,..) INSERT INTO INSERT INTO table_name VALUES (value1, value2, value3,....)or INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,....) INNER JOIN SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name LEFT JOIN SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name RIGHT JOIN SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name FULL JOIN SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name LIKE SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern ORDER BY SELECT column_name(s) FROM table_name ORDER BY column_name [ASC|DESC] SELECT SELECT column_name(s) FROM table_name SELECT * SELECT * FROM table_name SELECT DISTINCT SELECT DISTINCT column_name(s) FROM table_name SELECT INTO SELECT * INTO new_table_name [IN externaldatabase] FROM old_table_nameor SELECT column_name(s) INTO new_table_name [IN externaldatabase] FROM old_table_name SELECT TOP SELECT TOP number|percent column_name(s) FROM table_name TRUNCATE TABLE TRUNCATE TABLE table_name UNION SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2 UNION ALL SELECT column_name(s) FROM table_name1 UNION ALL SELECT column_name(s) FROM table_name2 UPDATE UPDATE table_name SET column1=value, column2=value,... WHERE some_column=some_value WHERE SELECT column_name(s) FROM table_name WHERE column_name operator value select *from s3_files.airdna_property_export_vacasa__2018_03_2 where country ilike 'chile'and city ilike 'alg%'limit 40 which city has the 3rd most air bnb units in argentina? who has more units, chile or argentina? how many units are in viña del mar? -- by city select country,city,count(property_id) as total from s3_files.airdna_property_export_vacasa__2018_03_21 where country ilike'Chile' group by city,country order by total desc; select city,property_id,count('annual_revenue_ltm_(usd)') as total,"annual_revenue_ltm_(usd)" from s3_files.airdna_property_export_vacasa__2018_03_21 where city ilike 'Algarrobo' group by city,property_id,"annual_revenue_ltm_(usd)" order by "annual_revenue_ltm_(usd)" des Are there more units in Pucon or Iquique? Pucon 1781 Iquique 1235 Which has the highest average daily rate... pucon or iquique?? Iquique 96.4210898203593 Pucon 145.0456861258529 Are there more units in Pucon or Iquique? Pucon 1781 Iquique 1235 Which has the highest average daily rate... pucon or iquique?? Pucon 66681.08483699772 Algarrobo 66170.39239007894 what is the owner.id that owns have the three-room apartment with the highest annual revenue in algarrobo which unit had the highest occupancy % in santiago in 2017?