일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Push
- pyhcarm
- PyCharm
- anaconda3
- GIT
- c#
- declare
- Delphi
- 백준
- python 3.7
- pythonanywhere
- advColumnGrid
- queryset
- delphi 10.3
- get_object_or_404
- 중복제거
- dbadvgrid
- 델파이
- python3
- rank
- MSSQL
- templates
- blog
- Django
- COMMIT
- TMS
- hackerrank
- Visual Studio
- HTML
- github
- Today
- Total
목록SQL (9)
DevHyun
원래 일자별 재고는 쿼리로 입/출고량을 출력하고 프로그램에서 반복문을 통해 구해주는 형식이었는데 이번 기회에 쿼리로 다 조회해 버리자! 라는 생각을 하게됨. '수불현황' 테이블 DATE,IN_QTY,OUT_QTY * 2021-09-01~2021-09-02 '1234' 약품에 대한 일자별 재고 현황 출력 예시 일자 입고 출고 재고량 2021-09-01 5 0 10(이월 재고 5) 2021-09-02 3 2 11 *'1234' 약품의 2021-09-01 이전까지 재고는 5개여서 2021-09-01에 입고 5개 까지 해서 총 재고량은 10개. -- @STOCK 변수 선언 DECLARE @STOCK int -- '1234' 약품의 이월 재고를 SELECT 하면서 @STOCK 변수에 입력 SELECT TOP 1 ..
1 : N의 관계인 테이블 A와 B를 JOIN 할 때, 테이블 B의 데이터는 한개만 가져오고 싶을 때, TABLE_A ( IDX INT, NAME VARCHAR ) TABLE_B ( IDX INT, COUNT INT, SUBJECT VARCHAR ) TABLE_A IDX NAME 1 김철수 2 나영희 3 박소영 TABLE_B IDX COUNT SUBJECT 1 1 국어 1 1 영어 2 5 도덕 3 4 체육 일반적으로 JOIN을 걸게되면 SELECT A.IDX, NAME,COUNT,SUBJECT FROM TABLE_A AS A LEFT JOIN TABLE_B AS B ON A.IDX = B.IDX IDX NAME COUNT SUBJECT 1 김철수 1 국어 1 김철수 1 영어 2 나영희 5 도덕 3 박소영..
www.hackerrank.com/domains/sql Amber's conglomerate corporation just acquired some new companies. Each of the companies follows this hierarchy: Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code. No..
www.hackerrank.com/domains/sql 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: ..
www.hackerrank.com/domains/sql Write a query to print all prime numbers less than or equal to 1000. Print your result on a single line, and use the ampersand (&) character as your separator (instead of a space). For example, the output for all prime numbers 이렇게 지정한 이유는 안쪽 WHILE문에서 @LOOP 보다 @SELF(자기자신)이 작을 경우 아예 WHILE문을 안타버려서 긴급 조치! 3 이상부터는 WHILE문 정상작동 하기때문에 @BOOL을 초기값인 FALSE로 지정. * 안쪽 WHILE문 : L..
www.hackerrank.com/domains/sql P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5): * * * * * * * * * * * * * * * Write a query to print the pattern P(20). 번역 : 5개부터 시작해서 하나씩 줄여나가면서 별을 찍었듯이 20개 부터 시작해서 별을 찍어라 프로그래밍 언어 시작할때 반복문 예제로 많이 쓰이는 그 문제! 풀이 : 일단 SELECT 문으로는 힘들것 같아서 프로시져를 사용하기로 생각했음! 생각보다 어려웠다. PRINT REPLICATE를 몰랐다면 못풀었을 듯.. REPLICATE 함수 자체는 원하는 숫자만큼 원하..
www.hackerrank.com/domains/sql Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the west..
www.hackerrank.com/domains/sql Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. For example, if there are three records in the table with CITY values 'New York', 'New York', 'Bengalaru', there are 2 dif..
www.hackerrank.com/domains/sql Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer. The STATION table is described as follows: where LAT_N is the northern latitude and LONG_W is the western longitude. 짧은 영어실력으로 번역하자면.. STATION 테이블의 CITY 필드를 추출해 내는 것이 목표이고, 조건은 ID가 EVEN(짝수) 일 것. 정렬 순서는 상관없고 중복제거 MSS..