본문 바로가기

분류 전체보기

(197)
[programmers] Java - Lv.0 배열 자르기 문제 풀이 class Solution { public int[] solution(int[] numbers, int num1, int num2) { int[] answer = new int[num2 - num1 + 1]; int cnt = 0; for(int i = num1; i
[programmers] MySQL - Lv.4 취소되지 않은 진료 예약 조회하기 (String, Date) 문제 풀이 SELECT b.apnt_no, a.pt_name, a.pt_no, b.mcdp_cd, c.dr_name, b.apnt_ymd from patient a join appointment b on a.pt_no = b.pt_no join doctor c on b.mddr_id = c.dr_id where b.mcdp_cd = 'CS' and b.apnt_ymd like '2022-04-13%' and b.apnt_cncl_yn = 'N' order by b.apnt_ymd
[programmers] Java - Lv.0 점의 위치 구하기 문제 풀이 class Solution { public int solution(int[] dot) { if(dot[0] > 0 && dot[1] > 0) { return 1; } else if(dot[0] 0) { return 2; } else if(dot[0] < 0 && dot[1] < 0) { return 3; } else { return 4; } } }
[programmers] MySQL - Lv.4 년, 월, 성별 별 상품 구매 회원 수 구하기 (group by) 문제 풀이 select b.year, b.month, a.gender, count(distinct(a.user_id)) users from user_info a join (select user_id, year(sales_date) year, month(sales_date) month from online_sale) b on a.user_id = b.user_id where a.gender is not null group by b.year, b.month, a.gender order by b.year, b.month, a.gender
[HackerRank] MySQL - Occupations 문제 Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Note: Print NULL when there are no more names corresponding to an occupation. Input Format The OCCUPATIONS table is described as follows: Occupation will only contain..
[MySQL] 서브쿼리 서브 쿼리는 SELECT 명령에 의한 데이터 질의로, 상부가 아닌 하부의 부수적인 질의를 의미한다. [SYNTAX] ( SELECT 명령 ) 서브 쿼리는 SQL 명령문 안에 지정하는 하부 SELECT 명령으로 괄호로 묶어 지정한다. 특히 서브 쿼리는 SQL 명령의 WHERE구에서 주로 사용된다. WHERE 구는 SELECT, DELETE, UPDATE 구에서 사용할 수 있는데 이들 중 어떤 명령에서든 서브 쿼리를 사용할 수 있다. DELETE의 WHERE구에서 서브 쿼리 사용하기 서브 쿼리를 사용해서 최솟값을 가지는 행을 삭제할 수 있지만, MySQL에서는 실행할 수 없다. 데이터를 추가하거나 갱신할 경우 동일한 테이블을 서브 쿼리에서 사용할 수 없도록 되어있기 때문이다. 에러를 발생하지 않고 실행하려면..
[Java] 상속이란? 객체 지향 프로그래밍의 중요한 특징 중 하나가 상속(inheritance)이다. B 클래스가 A 클래스를 상속받으면 B 클래스는 A 클래스의 멤버 변수와 메서드를 사용할 수 있다. 객체 지향 프로그램은 유지보수가 편하고 프로그램을 수정하거나 새로운 내용을 추가하는 것이 유연한데, 그 기반이 되는 기술이 바로 상속이다. 자바 문법으로 상속을 구현할 때는 extends 예약어를 사용한다. A가 가지고 있는 속성이나 기능을 추가로 확장하여 B 클래스를 구현한다는 뜻으로 사용하는 것이다. class B extends A { } 상속을 사용하여 고객 관리 프로그램 구현하기 👉[실습] Customer 클래스 구현하기 package inheritance; public class Customer { // 멤버 변수 p..
[programmers] Java - Lv.0 배열 원소의 길이 문제 풀이 class Solution { public int[] solution(String[] strlist) { int[] answer = new int[strlist.length]; for(int i = 0; i < strlist.length; i++) { answer[i] = strlist[i].length(); } return answer; } }