Giter Site home page Giter Site logo

leetcode's Introduction

Leetcode

leetcode's People

Contributors

cocorig avatar

Watchers

 avatar

leetcode's Issues

SQL GROUP BY 문

  • GROUP BY 문은 특정 열 값을 기준으로 결과를 그룹화할 때 사용한다.
  • 그룹화된 결과를 집계하기 위해 종종 집계 함수인 COUNT(), MAX(), MIN(), SUM(), AVG()와 함께 사용한다.
  • GROUP BY 문은 데이터를 특정 기준에 따라 그룹화하고, 각 그룹에 대해 집계 함수를 사용하여 그룹 내에서 원하는 연산을 수행함.

w3schools SQL GROUP BY 예시

mysql 공식문서

Example 1:

Input: 
Person table:
+----+---------+
| id | email   |
+----+---------+
| 1  | [email protected] |
| 2  | [email protected] |
| 3  | [email protected] |
+----+---------+
Output: 
+---------+
| Email   |
+---------+
| [email protected] |
+---------+
Explanation: [email protected] is repeated two times.

solution

SELECT email AS Email
FROM Person
GROUP BY email
HAVING COUNT(email) > 1;

SQL 에서 LEFT JOIN 구문


스크린샷 2023-12-23 오전 12 30 05
SELECT column_name(s) 
FROM table1  
LEFT JOIN table2  
ON table1.column_name = table2.column_name; 

  • table1의 내용은 그대로 있고 table2와 겹치는 부분의 내용을 추출한다.
  • table1의 내용과 일치되지 않는 구문은 null 값을 반환한다.

이미지출처 : w3schools

SQL 문자길이 구하기

  • content의 길이가 15이상인 id 구하기
Input: 
Tweets table:
+----------+----------------------------------+
| tweet_id | content                          |
+----------+----------------------------------+
| 1        | Vote for Biden                   |
| 2        | Let us make America great again! |
+----------+----------------------------------+
Output: 
+----------+
| tweet_id |
+----------+
| 2        |
+----------+
Explanation: 
Tweet 1 has length = 14. It is a valid tweet.
Tweet 2 has length = 32. It is an invalid tweet.
  • 출력 {"headers": ["tweet_id"], "values": [[2]]}
SELECT tweet_id 
FROM Tweets
WHERE LENGTH(content) > 15;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.