이 영역을 누르면 첫 페이지로 이동
쿄코코 블로그의 첫 페이지로 이동

쿄코코

페이지 맨 위로 올라가기

쿄코코

얼레벌레 생활🤯

HackerRank- Weather Observation Station 6,7,8,9

  • 2022.09.04 15:27
  • SQL/HackerRank
    반응형

     

    REGEXP 관련 정리된 게시물

     

    REGEXP,REGEXP_LIKE,REGEXP_INSTR,REGEXP_SUBSTR,REGEXP_REPLACE()

    참고 블로그 : https://goodteacher.tistory.com/232 MySQL :: MySQL 8.0 Reference Manual :: 12.8.2 Regular Expressions 12.8.2 Regular Expressions Table 12.14 Regular Expression Functions and Operato..

    coooco.tistory.com

     

    Weather Observation Station 6📝

    ➡️ STATION 테이블, 조건 : city a%, e% , i%, o%, u% -> 출력 : 중복되지 않는 city 

     

    Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

    Input Format

    The STATION table is described as follows:

    where LAT_N is the northern latitude and LONG_W is the western longitude.

     

    SELECT DISTINCT city 
    FROM station 
    WHERE (city LIKE 'A%' 
           OR city LIKE 'E%' 
           OR city LIKE 'I%' 
           OR city LIKE 'O%' 
           OR city LIKE 'U%');
    SELECT DISTINCT city 
    FROM station 
    WHERE city REGEXP '^[aeiou]';

     

     

    Weather Observation Station 7📝

    ➡️ STATION 테이블, 조건 : city %a, %e , %i, %o, %u -> 출력 : 중복되지 않는 city 

     

    Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.

    Input Format

    The STATION table is described as follows:

    where LAT_N is the northern latitude and LONG_W is the western longitude.

    SELECT DISTINCT city
    FROM station
    WHERE (city LIKE '%a'
          OR city LIKE '%e'
          OR city LIKE '%i'
          OR city LIKE '%o'
          OR city LIKE '%u');
    SELECT DISTINCT city
    FROM station
    WHERE city REGEXP '[aeiou]$';

     


     

    Weather Observation Station 8📝

     

    ➡️ STATION 테이블, 조건 : city a%(aeiou),e%(aeiou) ,i%(aeiou),o%(aeiou),u%(aeiou) -> 출력 : 중복되지 않는 city 

    ex )Acme , Aguanga, Alba, Aliso Viejo, Alpine 

    Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.

    Input Format

    The STATION table is described as follows:

    where LAT_N is the northern latitude and LONG_W is the western longitude.

     

    SELECT DISTINCT city
    FROM station
    WHERE city REGEXP '^[aeiou]'and city REGEXP'[aeiou]$';
    SELECT DISTINCT city
    FROM station
    WHERE REGEXP_LIKE (city,'^a|^e|^i|^o|^u') AND REGEXP_LIKE (city,'a$|e$|i$|o$|u$');
    
    SELECT DISTINCT city
    FROM station
    WHERE REGEXP_LIKE (city,'^[aeiou]') AND REGEXP_LIKE (city,'[aeiou]$');
    
    SELECT DISTINCT city
    FROM station
    WHERE REGEXP_LIKE (city,'^[aeiou].*[aeiou]$');

     


     

    Weather Observation Station 9📝

     

    ➡️ STATION 테이블, 조건 : a,e,i,o,u로 시작되지 않는 city 이름 -> 출력 : 중복되지 않는 city 

    -> Weather Obseration Station 6번에 not 또는 ^을 붙인다.

    Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

    Input Format

    The STATION table is described as follows:

    where LAT_N is the northern latitude and LONG_W is the western longitude.

    SELECT DISTINCT city 
    FROM station 
    WHERE NOT (city LIKE 'A%' 
                OR city LIKE 'E%' 
                OR city LIKE 'I%' 
                OR city LIKE 'O%' 
                OR city LIKE 'U%');
    SELECT DISTINCT city 
    FROM station 
    WHERE city REGEXP '^[^aeiou]';

     

     

    반응형

    'SQL > HackerRank' 카테고리의 다른 글

    Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)  (0) 2022.09.12
    HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names  (0) 2022.09.12
    HackerRank-Japanese Cities' Attributes, Japanese Cities' Names, Weather Observation Station 1, Weather Observation Station 3, Weather Observation Station 4 (COUNT(*))  (0) 2022.08.28
    HackerRank - Revising the Select Query I, Revising the Select Query II, Select All, Select By ID  (0) 2022.08.23
    HackerRank SQL 정리표 🗓  (0) 2022.08.23

    댓글

    이 글 공유하기

    • 구독하기

      구독하기

    • 카카오톡

      카카오톡

    • 라인

      라인

    • 트위터

      트위터

    • Facebook

      Facebook

    • 카카오스토리

      카카오스토리

    • 밴드

      밴드

    • 네이버 블로그

      네이버 블로그

    • Pocket

      Pocket

    • Evernote

      Evernote

    다른 글

    • Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)

      Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)

      2022.09.12
    • HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names

      HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names

      2022.09.12
    • HackerRank-Japanese Cities' Attributes, Japanese Cities' Names, Weather Observation Station 1, Weather Observation Station 3, Weather Observation Station 4 (COUNT(*))

      HackerRank-Japanese Cities' Attributes, Japanese Cities' Names, Weather Observation Station 1, Weather Observation Station 3, Weather Observation Station 4 (COUNT(*))

      2022.08.28
    • HackerRank - Revising the Select Query I, Revising the Select Query II, Select All, Select By ID

      HackerRank - Revising the Select Query I, Revising the Select Query II, Select All, Select By ID

      2022.08.23
    다른 글 더 둘러보기

    정보

    쿄코코 블로그의 첫 페이지로 이동

    쿄코코

    • 쿄코코의 첫 페이지로 이동

    검색

    메뉴

    • 홈

    카테고리

    • 분류 전체보기 (168)
      • Python (24)
        • 😈 99클럽 코테 스터디 4기 TIL (23)
        • 궁금한거 정리 (1)
      • SQL (16)
        • HackerRank (15)
      • [백준] Python,Java로 풀기📖 (71)
        • 정렬(Sorting) (6)
        • 그리디 (5)
        • 문자열 (7)
        • 수학 (3)
        • DFS&BFS (10)
        • 구현 (4)
        • 다이나믹 (17)
        • 이분탐색 (1)
        • 자료구조 (10)
        • 최단거리 (5)
        • 인덱스트리 (0)
      • [프로그래머스]Python,Java로 풀기 (6)
        • Level 1 (4)
        • Level 2 (2)
      • Study Platform📚 (25)
        • (운영체제) - 블로그 및 강의 참고 (0)
        • 김영한👨🏻‍🏫의 스프링 부트와 JPA 실무 완전 .. (5)
        • (알고리즘)- [이코테] 이것이 코딩테스트다 정리 (10)
        • 그림으로 배우는 Http&Network Basic (10)
      • 까먹을까봐 적는 것들 (4)
      • 테스트 보고 난 후..🤔 (0)
      • kt 에이블스쿨 (18)

    최근 글

    인기 글

    댓글

    공지사항

    아카이브

    태그

    • 프로그래머스
    • 코딩테스트준비
    • 백준
    • TiL
    • 티스토리챌린지
    • 항해99
    • 99클럽
    • 오블완

    나의 외부 링크

    정보

    쿄코코의 쿄코코

    쿄코코

    쿄코코

    블로그 구독하기

    • 구독하기
    • RSS 피드

    방문자

    • 전체 방문자
    • 오늘
    • 어제

    티스토리

    • 티스토리 홈
    • 이 블로그 관리하기
    • 글쓰기
    Powered by Tistory / Kakao. © 쿄코코. Designed by Fraccino.

    티스토리툴바