Back to articles
Basic Select SQL Queries

Basic Select SQL Queries

via Dev.to PythonAshiq Omar

Let me explain it with some Hackerank problems: QN: 1 Query all columns for a city in CITY with the ID 1661 ANS: SELECT * from CITY where ID = 1661; it is to select all columns from table city and the condition is for ID = 1661. QN: 2 Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN. ANS: SELECT * from CITY where COUNTRYCODE= 'JPN'; it is to select all attributes from the table city and the condition is for a COUNTRYCODE =JPN QN:3 Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA. ANS: SELECT NAME from CITY where POPULATION > 120000 and COUNTRYCODE = 'USA'; since it is to select all the names from the table city condition is population is more than 120000 and CountryCode =USA QN:4 Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates. ANS: SELECT DISTINCT CITY FROM STATION WHERE CITY NOT LIKE"A%" AND

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
6 views

Related Articles