[SQL]疲れたとき...SQLを見て...hackrank問題のクリア(2)
2244 ワード
Weather Observation Station 2
Query the following two values from the STATION table:
The sum of all values in LAT_N rounded to a scale of 2 decimal places.
The sum of all values in LONG_W rounded to a scale of 2 decimal places.
SELECT ROUND(SUM(LAT_N),2), ROUND(SUM(LONG_W),2)
FROM STATION
Weather Observation Station 18
SELECT ROUND(ABS(MIN(LAT_N) - MAX(LAT_N)) + ABS(MIN(LONG_W) - MAX(LONG_W)),4)
FROM STATION
私はNew Companies
Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code.
グループBye概念+distinctについて考えてこそ、よりよく理解することができる.
#초안
SELECT C.company_code,
C.founder,
COUNT(E.lead_manager_code),
COUNT(E.senior_manager_code),
COUNT(E.manager_code),
COUNT(E.employee_code)
FROM Employee AS E
INNER JOIN Company AS C
ON E.company_code = C.company_code
GROUP BY C.company_code
ORDER BY C.company_code
このようにして、また群死群傷のためにずっと困難を感じているようだ.サブクエリを作成しますか...?ずっとうろうろしています.
いろんなグループを探しているのでByQuery...隣にはもう一つのグループByColumが追加されました...
SELECT C.company_code,
C.founder,
COUNT(DISTINCT E.lead_manager_code),
COUNT(DISTINCT E.senior_manager_code),
COUNT(DISTINCT E.manager_code),
COUNT(DISTINCT E.employee_code)
FROM Employee AS E
INNER JOIN Company AS C
ON E.company_code = C.company_code
GROUP BY C.company_code, C.founder
ORDER BY C.company_code
duplicateに気づかなかったので、明らかではなく、ずっとミスをして、最後に成功しました.组み合わせも他の基础もしっかりしている気がします.
Reference
この問題について([SQL]疲れたとき...SQLを見て...hackrank問題のクリア(2)), 我々は、より多くの情報をここで見つけました https://velog.io/@cyanred9/SQL-힘들땐...SQL을-봐...hackerrank-문제-정리2テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol