Programmers(49)
-
[mysql / oracle] 가격대 별 상품 개수 구하기
문제 결과 mysql / oracle 1. case문 이용 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 SELECT (case when price >= 0 and price = 10000 and price = 20000 and price = 30000 and price = 40000 and price = 50000 and price = 60000 and price = 70000 and price = 80000 and price = 0 and price = 10000 and price = 20000 and price = 30000 and price = 40000 and price = 50000 and price = 60000 and pri..
2023.02.03 -
폰켓몬
문제 결과 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.util.*; class Solution { public int solution(int[] nums) { ArrayList phone = new ArrayList(); for(int i=0; i
2023.01.29 -
2016년
문제 결과 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public String solution(int a, int b) { String answer = ""; int[] months = {31,29,31,30,31,30,31,31,30,31,30,31}; int c = 0; for(int i=0; i
2023.01.29 -
두 개 뽑아서 더하기
문제 결과 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.util.*; class Solution { public Set solution(int[] numbers) { Set answer = new TreeSet(); for(int i=0; i
2023.01.29 -
[mysql/oracle] 자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기
문제 결과 mysql / oracle 1 2 3 4 5 SELECT car_type, count(*) cars from car_rental_company_car where options like '%시트%' group by car_type order by car_type cs 공교롭게도 요구한 통풍시트, 열선시트, 가죽시트 모두 '시트'가 들어가서 like와 와일드카드로 처리했다. 정규식으로도 가능하다. 1 2 3 4 5 SELECT car_type, count(*) cars from car_rental_company_car where options regexp '시트' group by car_type order by car_type cs 정규식 검색 . : 문자 하나 * : 앞에 나온 문자의 0개 이상..
2023.01.29 -
[mysql/oracle] 카테고리 별 상품 개수 구하기
문제 결과 mysql / oracle substr 1 2 3 4 5 SELECT substr(product_code,1,2) category , count(*) products from product group by substr(product_code,1,2) order by category cs 상품코드의 앞 2자리가 카테고리 코드이므로 2글자만 가져오기 위해 substr을 이용하였다. substr(문자열 or 컬럼명, 몇 번째 글자부터, 몇 글자나 자를 것인가) mysql left 1 2 3 4 5 SELECT left(product_code,2) category , count(*) products from product group by left(product_code,2) order by categ..
2023.01.29