Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.
The CITY table is described as follows:
인구가 0보다 큰 CITY 테이블 의 모든 미국 도시에 대해 모든 열을 쿼리합니다 100000. 미국의 국가 코드USA 는 입니다.
CITY 테이블 은 다음과 같이 설명됩니다.
select *
from city
where population > 100000 and countrycode = 'usa'
Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.
The CITY table is described as follows:
인구가 0보다 큰 CITY 테이블 의 모든 미국 도시에 대해 NAME 필드를 쿼리합니다 . 미국의 국가 코드 는 입니다 .120000USA
CITY 테이블 은 다음과 같이 설명됩니다.
select name
from city
where population > 120000 and countrycode = 'USA';
Query all columns (attributes) for every row in the CITY table.
The CITY table is described as follows:
CITY 테이블 의 모든 행에 대해 모든 열(속성)을 쿼리합니다 .
CITY 테이블 은 다음과 같이 설명됩니다.
select *
from city;
Query all columns for a city in CITY with the ID 1661.
The CITY table is described as follows:
ID 가 인 CITY 의 도시에 대한 모든 열을 쿼리합니다 . 1661
CITY 테이블 은 다음과 같이 설명됩니다.
select *
from city
where id = 1661;
Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.
The CITY table is described as follows:
CITY 테이블 에 있는 모든 일본 도시의 모든 속성을 쿼리합니다 . 일본의 국가 코드JPN 는 입니다 .
CITY 테이블 은 다음과 같이 설명됩니다.
select *
from city
where countrycode = 'jpn';
Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.
The CITY table is described as follows:
CITY 테이블 에 있는 모든 일본 도시의 이름을 쿼리합니다 . 일본의 국가 코드JPN 는 입니다 .
CITY 테이블 은 다음과 같이 설명됩니다.
select name
from city
where countrycode = 'jpn';
Query a list of CITY and STATE from the STATION table.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
STATION 테이블 에서 CITY 및 STATE 목록을 쿼리합니다 . STATION 테이블은 다음 과 같이 설명됩니다.
여기서 LAT_N은 북위이고 LONG_W 는 서경입니다.
select city, state
from station;
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
ID 번호 가 짝수인 도시에 대해 STATION 에서 CITY 이름 목록을 쿼리합니다 . 결과를 순서에 관계없이 인쇄하되 답에서 중복 항목을 제외합니다. STATION 테이블은 다음 과 같이 설명됩니다.
여기서 LAT_N은 북위이고 LONG_W 는 서경입니다.
select distinct(city)
from station
where id % 2 = 0
Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
For example, if there are three records in the table with CITY values 'New York', 'New York', 'Bengalaru', there are 2 different city names: 'New York' and 'Bengalaru'. The query returns , because
테이블의 총 CITY 항목 수와 테이블의 개별 CITY 항목 수 간의 차이를 찾으십시오.
STATION 테이블은 다음 과 같이 설명됩니다.
여기서 LAT_N은 북위이고 LONG_W 는 서경입니다.
예를 들어 테이블에 CITY 값이 'New York', 'New York', 'Bengalaru'인 세 개의 레코드가 있는 경우 'New York'과 'Bengalaru'라는 두 개의 다른 도시 이름이 있습니다. 쿼리가 반환합니다.
select count(city) - count(distinct(city))
from station;
Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
가장 짧은 CITY 이름과 가장 긴 CITY 이름 및 각각의 길이(예: 이름의 문자 수)를 사용하여 STATION 의 두 도시를 쿼리합니다 . 가장 작은 도시 또는 가장 큰 도시가 둘 이상인 경우 알파벳순으로 정렬할 때 먼저 오는 도시를 선택하십시오. STATION 테이블은 다음 과 같이 설명됩니다.
여기서 LAT_N은 북위이고 LONG_W 는 서경입니다.
For example, CITY has four entries: DEF, ABC, PQRS and WXY.
예를 들어 CITY에는 DEF, ABC, PQRS 및 WXY 의 네 가지 항목이 있습니다 .
ABC 3
PQRS 4
When ordered alphabetically, the CITY names are listed as ABC, DEF, PQRS, and WXY, with lengths and . The longest name is PQRS, but there are options for shortest named city. Choose ABC, because it comes first alphabetically.
알파벳순으로 주문하면 CITY 이름은 길이가 있는 ABC, DEF, PQRS 및 WXY 로 나열됩니다 . 3,3,4,그리고 3. 가장 긴 이름은 PQRS 이지만 다음이 있습니다.이름이 가장 짧은 도시에 대한 옵션. 알파벳순으로 먼저 오므로 ABC 를 선택합니다 .
You can write two separate queries to get the desired output. It need not be a single query.
원하는 출력을 얻기 위해 두 개의 개별 쿼리를 작성할 수 있습니다. 단일 쿼리일 필요는 없습니다.
select city, length(city)
from station
order by length(city), city
limit 1;
select city, length(city)
from station
order by length(city) desc, city desc
limit 1;
정보에 감사드립니다.