From 51ea9f7f0f22d776fc892145e28b4ad75de20342 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Tue, 3 Dec 2024 10:52:29 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201194?= =?UTF-8?q?=20=EB=8B=AC=EC=9D=B4=20=EC=B0=A8=EC=98=A4=EB=A5=B8=EB=8B=A4,?= =?UTF-8?q?=20=EA=B0=80=EC=9E=90.=5F241203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1194.java" | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1194.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1194.java" "b/BOJ/1000-5000353円262円210円/SB_1194.java" new file mode 100644 index 00000000..70a275fb --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1194.java" @@ -0,0 +1,100 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class SB_1194 { + static int N, M; + static char[][] board; + static Node start; + static int ans = Integer.MAX_VALUE; + static int[][][] visited; + static int[] dx = {-1, 1, 0, 0}; + static int[] dy = {0, 0, -1, 1}; + + private static void bfs() { + Queue que = new ArrayDeque(); + visited[start.x][start.y][0] = 0; + que.offer(new Node(start.x, start.y, 0)); + + while (!que.isEmpty()) { + Node cur = que.poll(); + + if (board[cur.x][cur.y] == '1') { + ans = Math.min(ans, visited[cur.x][cur.y][cur.keys]); + continue; + } + + for (int i = 0; i < 4; i++) { + int nx = cur.x + dx[i]; + int ny = cur.y + dy[i]; + int nk = cur.keys; + if (!isValid(nx, ny) || board[nx][ny]=='#' || visited[nx][ny][nk]!=-1) continue; + + char nxt = board[nx][ny]; + // 이동할 곳이 알파벳일 경우 + if (Character.isAlphabetic(nxt)){ + if (Character.isLowerCase(nxt)) nk |= (1 << (nxt - 'a')); // 키면 키 줍기 + else if (Character.isUpperCase(nxt)) { + if ((nk & (1<< (nxt-'A')))==0) continue; // 키 없는 문은 못감 + } + } + + // 이동 가능할 경우 이동 + que.offer(new Node(nx, ny, nk)); + visited[nx][ny][nk] = visited[cur.x][cur.y][cur.keys] + 1; + } + } + } + + private static boolean isValid(int x, int y) { + return 0 <= x && x < N && 0 <= y && y < M; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + board = new char[N][M]; + visited = new int[N][M][1 << 6]; // 키 6개 존재 2^6 + for (int i = 0; i < N; i++) { + String line = br.readLine(); + for (int j = 0; j < M; j++) { + board[i][j] = line.charAt(j); + if (board[i][j]=='0'){ + start = new Node(i, j, 0); + board[i][j] = '.'; + } + } + } + + for (int i = 0; i < N; i++) { // 방문배열 초기화 + for (int j = 0; j < M; j++) { + Arrays.fill(visited[i][j], -1); + } + } + + bfs(); + System.out.println(ans==Integer.MAX_VALUE ? -1 : ans); + } + static class Node{ + int x, y, keys; + + public Node(int x, int y, int keys) { + this.x = x; + this.y = y; + this.keys = keys; + } + + @Override + public String toString() { + return "Node{" + + "x=" + x + + ", y=" + y + + ", keys=" + keys + + '}'; + } + } +} From 8a844bae38c1066a1c6e0b37c9337989aff18bf3 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Tue, 3 Dec 2024 11:17:10 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=205?= =?UTF-8?q?=EC=9B=94=20=EC=8B=9D=ED=92=88=EB=93=A4=EC=9D=98=20=EC=B4=9D?= =?UTF-8?q?=EB=A7=A4=EC=B6=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98=EA=B8=B0=5F241?= =?UTF-8?q?203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354円241円260円355円232円214円355円225円230円352円270円260円.sql" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "SQL/13354円243円274円354円260円250円/SB_5354円233円224円 354円213円235円355円222円210円353円223円244円354円235円230円 354円264円235円353円247円244円354円266円234円 354円241円260円355円232円214円355円225円230円352円270円260円.sql" diff --git "a/SQL/13354円243円274円354円260円250円/SB_5354円233円224円 354円213円235円355円222円210円353円223円244円354円235円230円 354円264円235円353円247円244円354円266円234円 354円241円260円355円232円214円355円225円230円352円270円260円.sql" "b/SQL/13354円243円274円354円260円250円/SB_5354円233円224円 354円213円235円355円222円210円353円223円244円354円235円230円 354円264円235円353円247円244円354円266円234円 354円241円260円355円232円214円355円225円230円352円270円260円.sql" new file mode 100644 index 00000000..c66c72ed --- /dev/null +++ "b/SQL/13354円243円274円354円260円250円/SB_5354円233円224円 354円213円235円355円222円210円353円223円244円354円235円230円 354円264円235円353円247円244円354円266円234円 354円241円260円355円232円214円355円225円230円352円270円260円.sql" @@ -0,0 +1,9 @@ +-- 코드를 입력하세요 +-- 생산일자가 2022년 5월인 식품들의 식품 ID, 식품 이름, 총매출을 조회하는 SQL문을 작성 + +SELECT p.PRODUCT_ID, p.PRODUCT_NAME, SUM(p.PRICE*o.AMOUNT) AS TOTAL_SALES +FROM FOOD_PRODUCT p +JOIN FOOD_ORDER o ON p.PRODUCT_ID = o.PRODUCT_ID +WHERE DATE_FORMAT(o.PRODUCE_DATE, '%Y-%m') = '2022-05' +GROUP BY p.PRODUCT_ID, p.PRODUCT_NAME +ORDER BY TOTAL_SALES DESC, p.PRODUCT_ID; \ No newline at end of file From 9ee7a1173618d411752657e7763b4ce915b559be Mon Sep 17 00:00:00 2001 From: baexxbin Date: Wed, 4 Dec 2024 10:24:49 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=208979?= =?UTF-8?q?=20=EC=98=AC=EB=A6=BC=ED=94=BD=5F241204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/5001-10000353円262円210円/SB_8979.java" | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "BOJ/5001-10000353円262円210円/SB_8979.java" diff --git "a/BOJ/5001-10000353円262円210円/SB_8979.java" "b/BOJ/5001-10000353円262円210円/SB_8979.java" new file mode 100644 index 00000000..08950d9f --- /dev/null +++ "b/BOJ/5001-10000353円262円210円/SB_8979.java" @@ -0,0 +1,65 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class SB_8979 { + static int N, K; + static List nations = new ArrayList(); + private static int medal2Int(int g, int s, int b){ + return g * 1000000 + s * 1000 + b; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + int idx = Integer.parseInt(st.nextToken()); + int g = Integer.parseInt(st.nextToken()); + int s = Integer.parseInt(st.nextToken()); + int b = Integer.parseInt(st.nextToken()); + nations.add(new Nation(idx, medal2Int(g, s, b))); + } + + Collections.sort(nations); + + int rank = 1; + int tmp = 1; // 동점자 처리를 위한 변수(매번 증가) + int preScore = nations.get(0).score; + for (Nation cur : nations) { + if (cur.score != preScore) rank = tmp; // 서로 점수가 다르면 순위 갱신 + if (cur.idx==K){ // 찾는 나라면 순위 출력 + System.out.println(rank); + return; + } + tmp++; + preScore = cur.score; + } + } + + static class Nation implements Comparable{ + int idx, score; + + public Nation(int idx, int score) { + this.idx = idx; + this.score = score; + } + + @Override + public int compareTo(Nation o) { + return o.score - this.score; + } + + @Override + public String toString() { + return "Nation{" + + "idx=" + idx + + ", score=" + score + + '}'; + } + } +} From e90ff099e7e1463674718a7907e7e9669fec7079 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Thu, 5 Dec 2024 15:59:35 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201749?= =?UTF-8?q?=20=EC=A0=90=EC=88=98=20=EB=94=B0=EB=A8=B9=EA=B8=B0=5F241205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1749.java" | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1749.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1749.java" "b/BOJ/1000-5000353円262円210円/SB_1749.java" new file mode 100644 index 00000000..dacf977a --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1749.java" @@ -0,0 +1,45 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class SB_1749 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + int[][] board = new int[N][M]; + long[][] dp = new long[N + 1][M + 1]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < M; j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + } + + // 누적합 계산 + for (int i = 1; i < N + 1; i++) { + for (int j = 1; j < M + 1; j++) { + dp[i][j] = board[i-1][j-1] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]; + } + } + + // 부분 행렬의 최대값 찾기 + long mx = Long.MIN_VALUE; + for (int r1 = 1; r1 < N + 1; r1++) { + for (int c1 = 1; c1 <= M + 1; c1++) { + for (int r2 = r1; r2 <= N; r2++) { + for (int c2 = c1; c2 <= M; c2++) { + long tmp = dp[r2][c2] - dp[r1 - 1][c2] - dp[r2][c1 - 1] + dp[r1 - 1][c1 - 1]; + mx = Math.max(mx, tmp); + } + } + } + } + + System.out.println(mx); + } +} From 4a9fc9bf688cd078bdaf20c3378e10532dba16ef Mon Sep 17 00:00:00 2001 From: baexxbin Date: Fri, 6 Dec 2024 11:04:08 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201503?= =?UTF-8?q?67=20=ED=91=9C=ED=98=84=20=EA=B0=80=EB=8A=A5=ED=95=9C=20?= =?UTF-8?q?=EC=9D=B4=EC=A7=84=ED=8A=B8=EB=A6=AC=5F241206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level3/SB_150367.java | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Programmers/Level3/SB_150367.java diff --git a/Programmers/Level3/SB_150367.java b/Programmers/Level3/SB_150367.java new file mode 100644 index 00000000..311aeb3c --- /dev/null +++ b/Programmers/Level3/SB_150367.java @@ -0,0 +1,42 @@ +class SB_150367 { + private static boolean dfs(String sub) { + int root = sub.length() / 2; + + if (sub.length() ==1) return true; + + // 부모가 없는데 자식이 존재하면 이진트리 구성 못함 + if (sub.charAt(root)=='0' && (sub.substring(0, root).contains("1") || sub.substring(root+1).contains("1"))) return false; + + // 양쪽 모두 모순이 없을 경우 true + return dfs(sub.substring(0, root)) && dfs(sub.substring(root + 1)); + } + + private static String num2bin(long num) { + StringBuilder bin = new StringBuilder(Long.toBinaryString(num)); + long len = bin.length(); + int n = 0; + while ((1L << n) - 1 < len) { // 2^n-1로 자리를 맞추기 위한 n찾기 + n++; + } + + while (bin.length() < (1 << n) - 1) { // 2^n-1로 길이 맞추기 + bin.insert(0, "0"); + } + + return bin.toString(); + } + public static int[] solution(long[] numbers) { + int N = numbers.length; + int[] ans = new int[N]; + + for (int i = 0; i < N; i++) { + // 이진수로 만들기 + String bin = num2bin(numbers[i]); + + // 부모 자식 연결 확인 + ans[i] = dfs(bin) ? 1 : 0; + } + + return ans; + } +} \ No newline at end of file From 13c2cb7a2cc473060a227d57a151ea107659fba0 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Fri, 6 Dec 2024 11:25:57 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[PG]=2025013?= =?UTF-8?q?5=20=EC=95=84=EB=82=A0=EB=A1=9C=EA=B7=B8=20=EC=8B=9C=EA=B3=84?= =?UTF-8?q?=5F241206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/SB_250135.java | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Programmers/Level2/SB_250135.java diff --git a/Programmers/Level2/SB_250135.java b/Programmers/Level2/SB_250135.java new file mode 100644 index 00000000..e2a3353c --- /dev/null +++ b/Programmers/Level2/SB_250135.java @@ -0,0 +1,60 @@ +class SB_250135 { + private static boolean overlapHour(Time cur, Time nxt) { + if(cur.dh> cur.ds && nxt.dh <=nxt.ds) return true; + return cur.ds == 354 && cur.dh> 354; + } + private static boolean overlapMin(Time cur, Time nxt) { + if(cur.dm> cur.ds && nxt.dm <=nxt.ds) return true; + return cur.ds == 354 && cur.dm> 354; // 초침이 정각으로 갈때 0도 처리 + } + public static int solution(int h1, int m1, int s1, int h2, int m2, int s2) { + int startTime = new Time(h1, m1, s1).getSecond(); + int endTime = new Time(h2, m2, s2).getSecond(); + + int cnt = 0; + for (int i = startTime; i < endTime; i++) { + Time cur = new Time(i); + Time nxt = new Time(i + 1); + + boolean isMinRing = overlapMin(cur, nxt); + boolean isHourRing = overlapHour(cur, nxt); + + if (isMinRing && isHourRing){ // 시침 분침 모두 겹쳤을때 + if (nxt.dh== nxt.dm) cnt++; // 시침분침의 위치가 같으면 한번만 카운트 + else cnt+=2; + } else if (isMinRing || isHourRing) cnt++; + } + if (startTime==0 || startTime==43200) cnt++; // 예외처리: 처음에 시분초 모두 같이 있을 경우(정오, 정각) + return cnt; + } + + static class Time{ + int h, m, s; + double dh, dm, ds; + + public Time(int h, int m, int s) { + this.h = h; + this.m = m; + this.s = s; + setDegrees(); + } + + public Time(int s) { + this.h = s / 3600; + this.m = (s % 3600) / 60; + this.s = (s % 3600) % 60; + setDegrees(); + } + + + private int getSecond() { + return h * 3600 + m * 60 + s; + } + + private void setDegrees() { + this.dh = (h % 12) * 30d + m * 0.5 + s * (0.5 / 60); + this.dm = m * 6 + s * 0.1; + this.ds = s * 6; + } + } +} \ No newline at end of file From a7fc3471c36e771d89c70ef3e615edbe7c9e76d1 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Fri, 6 Dec 2024 13:25:27 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[CT]=20?= =?UTF-8?q?=EC=88=A0=EB=9E=98=EC=9E=A1=EA=B8=B0=20=EC=B2=B4=EC=8A=A4=5F241?= =?UTF-8?q?206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...352270円260円_354円262円264円354円212円244円.java" | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 "CodeTree/2019-2020353円205円204円/SB_354円210円240円353円236円230円354円236円241円352円270円260円_354円262円264円354円212円244円.java" diff --git "a/CodeTree/2019-2020353円205円204円/SB_354円210円240円353円236円230円354円236円241円352円270円260円_354円262円264円354円212円244円.java" "b/CodeTree/2019-2020353円205円204円/SB_354円210円240円353円236円230円354円236円241円352円270円260円_354円262円264円354円212円244円.java" new file mode 100644 index 00000000..a335f587 --- /dev/null +++ "b/CodeTree/2019-2020353円205円204円/SB_354円210円240円353円236円230円354円236円241円352円270円260円_354円262円264円354円212円244円.java" @@ -0,0 +1,142 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class SB_술래잡기_체스 { + static int mx = -1; + static int[] dx = {-1, -1, 0, 1, 1, 1, 0, -1}; + static int[] dy = {0, -1, -1, -1, 0, 1, 1, 1}; + + private static int[][] copyBoard(int[][] board) { + int[][] tmp = new int[4][4]; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + tmp[i][j] = board[i][j]; + } + } + return tmp; + } + + private static List copyPiece(List pieces) { + List tmpList = new ArrayList(); + for (Piece p : pieces) { + tmpList.add(new Piece(p.idx, p.x, p.y, p.dir, p.isDie)); + } + return tmpList; + } + private static void dfs(Tagger it, int[][] board, List pieces) { + // 도둑말들 움직이기 + moveThief(board, pieces); + + // 현재 방향으로 잡을 수 있는 말 잡기(최대 3번 이동 가능) + for (int i = 1; i < 4; i++) { + int nx = it.x + dx[it.dir] * i; + int ny = it.y + dy[it.dir] * i; + + if (isValid(nx, ny) && board[nx][ny] != 0) { + int[][] tmpBoard = copyBoard(board); + List tmpPiece = copyPiece(pieces); + + tmpBoard[it.x][it.y] = 0; + Piece thief = tmpPiece.get(board[nx][ny]); + Tagger nit = new Tagger(thief.x, thief.y, thief.dir, it.cnt + thief.idx); + thief.isDie = true; + tmpBoard[thief.x][thief.y] = -1; + + dfs(nit, tmpBoard, tmpPiece); + } + } + mx = Math.max(mx, it.cnt); + } + + + private static void moveThief(int[][] board, List pieces) { + for (Piece cur : pieces) { + if (cur.idx == 0 || cur.isDie) continue; // 죽었거나 술래면 스킵 + for (int d = 0; d < 8; d++) { + int nd = (cur.dir + d) % 8; + int nx = cur.x + dx[nd]; + int ny = cur.y + dy[nd]; + if (!isValid(nx, ny) || board[nx][ny] == -1) continue; + board[cur.x][cur.y] = 0; + if (board[nx][ny] == 0) cur.setPos(nx, ny); // 빈칸이면 바로 이동 + else { // 다른말있으면 교환 + Piece target = pieces.get(board[nx][ny]); + target.setPos(cur.x, cur.y); + board[cur.x][cur.y] = target.idx; + cur.setPos(nx, ny); + } + board[nx][ny] = cur.idx; // 움직일 보드에 현재 말 놓기 + cur.dir = nd; // 현재 말의 방향 갱신 + break; + } + } + } + + private static boolean isValid(int x, int y) { + return 0 <= x && x < 4 && 0 <= y && y < 4; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int[][] board = new int[4][4]; // 말들의 번호로 저장 + List pieces = new ArrayList(); + + for (int i = 0; i < 4; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < 4; j++) { + int num = Integer.parseInt(st.nextToken()); + int dir = Integer.parseInt(st.nextToken()) - 1; + Piece piece = new Piece(num, i, j, dir, false); + pieces.add(piece); + board[i][j] = num; + } + } + + // 도둑말 인덱스 순으로 정렬 + pieces.add(new Piece(0, -1, -1, 0, false)); // 인덱스 0맞추기 위해 더미 객체 넣기 + pieces.sort(((o1, o2) -> o1.idx - o2.idx)); + + // 초기 0,0 도둑말 잡기 + Piece first = pieces.get(board[0][0]); + Tagger tagger = new Tagger(0, 0, first.dir, first.idx); + board[0][0] = -1; + first.isDie = true; + + // 술래말의 재귀 시작 + dfs(tagger, board, pieces); + + System.out.println(mx); + } + + static class Tagger{ + int x, y, dir, cnt; + + public Tagger(int x, int y, int dir, int cnt) { + this.x = x; + this.y = y; + this.dir = dir; + this.cnt = cnt; + } + } + + static class Piece{ + int idx, x, y, dir; + boolean isDie; + + public Piece(int idx, int x, int y, int dir, boolean isDie) { + this.idx = idx; + this.x = x; + this.y = y; + this.dir = dir; + this.isDie = isDie; + } + + private void setPos(int x, int y) { + this.x = x; + this.y = y; + } + } +} From 5ab0fed9e14d0a8b74257c1f20938dfa4087d154 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Fri, 6 Dec 2024 14:50:55 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Movi?= =?UTF-8?q?e=20Rating=5F241206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SB_Movie Rating.sql" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "SQL/13354円243円274円354円260円250円/SB_Movie Rating.sql" diff --git "a/SQL/13354円243円274円354円260円250円/SB_Movie Rating.sql" "b/SQL/13354円243円274円354円260円250円/SB_Movie Rating.sql" new file mode 100644 index 00000000..a68d31fb --- /dev/null +++ "b/SQL/13354円243円274円354円260円250円/SB_Movie Rating.sql" @@ -0,0 +1,18 @@ +# Write your MySQL query statement below +-- 가장 많은 수의 영화를 평가한 사용자의 이름을 찾으세요. 동점일 경우, 사전학적으로 더 작은 사용자 이름을 반환하십시오. +-- 2020 2월 평균 평점이 가장 높은 영화 이름을 찾아라. 동점일 경우, 사전학적으로 더 작은 영화 이름을 반환하십시오. + +(SELECT u.name AS results +FROM MovieRating m +JOIN Users u ON m.user_id = u.user_id +GROUP BY u.user_id +ORDER BY COUNT(u.user_id) DESC, u.name +LIMIT 1) +UNION ALL +(SELECT m.title AS results +FROM MovieRating r +JOIN Movies m ON r.movie_id = m.movie_id +WHERE DATE_FORMAT(r.created_at, '%Y-%m') = "2020-02" +GROUP BY r.movie_id +ORDER BY AVG(r.rating) DESC, m.title +LIMIT 1) \ No newline at end of file

AltStyle によって変換されたページ (->オリジナル) /