/* Updating the file record after writing to the file */
UPDATE file_system
SET file_modified_date = '1980-02-22 13:19:01.00000',
file_size = 209732
WHERE file_name = '.vimrc';
YYYY-MM-DD HH:MM:SS.SSSSS
).WHERE cust_date between '2012-03-11 00:00:00' and '2012-05-11 23:59:00'이 더 낫습니다. → 연산이 더 적어짐
1. WHERE SUBSTR(EMPNAME,1,5) = 'david' -> WHERE EMPNAME LIKE 'david%'
2. WHERE EMPNAME||DEPTNAME = 'DAVIDSERVICE' -> WHERE EMPNAME = 'DAVID' AND DEPTNAME = 'SERVICE'
3. WHERE SAL + 1000 < 2000 -> WHERE SAL < 1000
staff
대신 employees
또는 people
대신 individuals
.date
또는 month
열 이름 과 같은 키워드를 사용하지 마십시오 .SELECT column1,
column2,
column3
FROM table
AS
키워드를 포함하십시오. 명시적이므로 읽기 쉽습니다.card_info 가 있는데 card_cust 가 나타나는 경우 각각 ci cc)
date_details.fiscal_quarter 라면 각각 dd fq
SUM(),
AVG()등
)의 경우 스키마에 정의된 열인 경우 지정한 이름을 사용합니다.SELECT first_name AS fn
FROM staff AS s1
JOIN students AS s2
ON s2.mentor_id = s1.staff_num;
ABSOLUTE
) ABS
.'
) 로 둘러쌓는 경우에 공백을 사용합니다.SELECT a.title, a.release_date, a.recording_date
FROM albums AS a
WHERE a.title = 'Charcoal Lane'
OR a.title = 'The New Danger';
AND
또는OR
사용시에 줄바꿈/ 세로 공백을 포함합니다.INSERT INTO albums (title, release_date, recording_date)
VALUES ('Charcoal Lane', '1990-01-01 01:01:01.00000', '1990-01-01 01:01:01.00000'),
('The New Danger', '2008-01-01 01:01:01.00000', '1990-01-01 01:01:01.00000');
SELECT r.last_name
FROM riders AS r
INNER JOIN bikes AS b
ON r.bike_vin_num = b.vin_num
AND b.engine_tally > 2
INNER JOIN crew AS c
ON r.crew_chief_last_name = c.last_name
AND c.chief = 'Y';
SELECT r.last_name,
(SELECT Max(Year(championship_date))
FROM champions AS c
WHERE c.last_name = r.last_name
AND c.confirmed = 'Y') AS last_championship_year
FROM riders AS r
WHERE r.last_name IN (SELECT c.last_name
FROM champions AS c
WHERE Year(championship_date) > '2008'
AND c.confirmed = 'Y');
replace_sfdc_account_id_with_master_record_id
!=
to <>
LOWER(column) LIKE '%match%'
to column ILIKE '%Match%'
WHERE
to HAVING
(둘 다 가능하다면)extract < **date_part**
~~Sub-query
보다 CTE
를 선호 합니다 .~~~~UNION ALL
보다 Window Function
을 선호합니다.~~~~CASE
문보다 IF
문을 선호합니다. (한줄에서만)~~SELECT DISTINCT A.deptname
FROM dept A,
emp B
WHERE A.deptno = B.deptno
SELECT A.deptname
FROM dept A
WHERE EXISTS (SELECT 1
FROM emp B
WHERE A.deptno = e.deptno)
https://www.dpriver.com/pp/sqlformat.htm
여기서
Output: | SQL(html:span) |
---|---|
Keywords case | default |
Table name case | default |
Column name case: | default |
Function case | default |
Datatype case | default |
Variable case | default |
Alias case | default |
Quoted identifier case | default |
Other identifier case | default |
Linebreaks with comma: Before
List and Parameters Style: Stacked
Stacked align: Align left
Max length per line in compact mode: 80
https://about.gitlab.com/handbook/business-technology/data-team/platform/sql-style-guide/