๐Ÿฌ MySQL/๋ฌธ์ œํ’€์ด

- ์ •๊ทœํ‘œํ˜„์‹์ด๋ž€? : ๋ฌธ์ž์—ด์—์„œ ํŒจํ„ด์„ ์ฐพ์•„๋‚ด๋Š” ์ผ์ข…์˜ ๊ทœ์น™ -> ์‹ค์ œ๋กœ ์ •๊ทœํ‘œํ˜„์‹์„ ๋‹ค ์•Œ๊ณ  ์“ฐ๋Š” ์‚ฌ๋žŒ์€ ๊ฑฐ์˜ ์—†์Œ.(๊ฒ€์ƒ‰์„ ํ•ด์„œ ์“ฐ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋Œ€๋ถ€๋ถ„) -> ์ •๊ทœํ‘œํ˜„์‹์ด ์ด๋Ÿฐ๊ฑฐ๊ตฌ๋‚˜ ํ•˜๋Š” ์ดํ•ด์™€ ํŠœํ† ๋ฆฌ์–ผ ์‚ฌ์ดํŠธ์—์„œ ์กฐ๊ธˆ ์—ฐ์Šต์„ ํ•ด๋ณธ ํ›„์— ๊ทธ ๋‹ค์Œ๋ถ€ํ„ฐ๋Š” ํ•„์š”ํ•  ๋•Œ๋งˆ๋‹ค ๊ฒ€์ƒ‰์„ ํ•ด์„œ ์ฐพ์•„์“ธ ์ˆ˜ ์žˆ๋Š” ์ •๋„๋กœ ํ•™์Šตํ•  ๊ฒƒ. 1. ๋ฌธ์ œ Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates. where LAT_N is the northern latitude and LONG_W is the western longitude. -> STATION ํ…Œ์ด..
1. ๋ฌธ์ œ We define an employee's total earnings to be their monthly salary x months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as 2 space-separated integers. The Emplo..
*FROM์ ˆ, WHERE์ ˆ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์„œ๋ธŒ์ฟผ๋ฆฌ : ๊ฐ€์ƒ์˜ ํ…Œ์ด๋ธ”์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ ๋‹ค๋ผ๊ณ  ์ƒ๊ฐ Task : ๊ฐ ์ฃผ์˜ ํ‰๊ท  ๋ฒ”์ฃ„๋ฐœ์ƒ์„ COUNT ๋งค์ผ ๋ฒ”์ฃ„๊ฐ€ ๋ช‡๋ฒˆ ๋ฐœ์ƒํ–ˆ๋Š”์ง€๋ฅผ ํŒŒ์•…(์„œ๋ธŒ์ฟผ๋ฆฌ) -> ์ปฌ๋Ÿผ(week, date, incident_daily) ๊ฒฐ๊ณผ๋ฌผ : (2+1+3+1+1+1+2)/7 -> ๋งŒ์•ฝ 2020-01-06์— ๋ฒ”์ฃ„๊ฐ€ ์ผ์–ด๋‚˜์ง€ ์•Š์•„์„œ nan๊ฐ’์ผ๋•Œ๋Š” ์„œ๋ธŒ์ฟผ๋ฆฌ๊ฐ€ 2020-01-06์˜ incident_daily๋ฅผ ๊ณ„์‚ฐํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— (2+3+1+1+1+2)/6์œผ๋กœ ๊ณ„์‚ฐ์ด ๋จ. ํ•˜์ง€๋งŒ ์šฐ๋ฆฌ๋Š” 2020-01-06์˜ incident_daily๋ฅผ 0๊ฑด์œผ๋กœ ๋†“๊ณ  ๊ณ„์‚ฐํ•˜๊ณ  ์‹ถ์€ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์‹ค์ƒ ๊ณ„์‚ฐ์€ (2+0+3+1+1+1+2)/7๋กœ ๊ณ„์‚ฐ์ด ๋˜์–ด์•ผํ•œ๋‹ค๋Š” ์ ์— ์œ ์˜ํ•  ๊ฒƒ! -> ํ‰๊ท , ๋‚ ์งœํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ..
1. ๋ฌธ์ œ 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 Y..
1. ๋ฌธ์ œ Query the difference between the maximum and minimum populations in CITY. 2. ๋‚ดํ’€์ด SELECT MAX(POPULATION) - MIN(POPULATION) FROM CITY 3. ๊ฒฐ๊ณผ
1. ๋ฌธ์ œ Query the average population for all cities in CITY, rounded down to the nearest integer. -> rounded down : ๋ฒ„๋ฆผ 2. ๋‚ดํ’€์ด CEIL() : ์˜ฌ๋ฆผ ex) SELECT CEIL(5.5) => 6 FLOOR() : ๋‚ด๋ฆผ ex) SELECT FLOOR(5.5) => 5 ROUND() : ๋ฐ˜์˜ฌ๋ฆผ ex) ROUND(5.556901, 4) => 5.5569 SELECT FLOOR(AVG(POPULATION)) FROM CITY -> ๋‚ด๋ฆผ์„ ์œ„ํ•ด FLOOR()ํ•จ์ˆ˜๋กœ ๊ฐ์‹ธ์คŒ 3. ๊ฒฐ๊ณผ
1. ๋ฌธ์ œ Query a count of the number of cities in CITY having a Population larger than 100,000. (larger than=์ดˆ๊ณผ) 2. ๋‚ดํ’€์ด SELECT COUNT(ID) FROM CITY WHERE POPULATION > 100000 3. ๊ฒฐ๊ณผ
1. ๋ฌธ์ œ Query the total population of all cities in CITY where District is California. 2. ๋‚ดํ’€์ด SELECT SUM(POPULATION) FROM CITY WHERE DISTRICT="California" 3. ๊ฒฐ๊ณผ
xod22
'๐Ÿฌ MySQL/๋ฌธ์ œํ’€์ด' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก