SQL(3)
-
Sequence of SQL calculation
1. Single Query 2. Multiple tables 3. Hence, - when you need single values or list, it would be more efficient executing in a single table than using several ctes - focus on Where and Select stages as following : Example 1: select customer_id, cost from Customer where customer_id in (select customer_id from Customer) Example 2: select purchase_amount >(select avg(purchase_amount) from Customer) ..
2022.05.20 -
hive sql - 다양한 group by - grouping sets , with cube
select A,B,C, count(distinct cust_id) from dataset group by A,B,C 1. grouping sets select A,B,C, grouping__id, count(distinct cust_id) from dataset group by A,B,C grouping sets ((),(A),(B),(C),(A,C),(B,C),(A,B,C)) 2. cube select A,B,C, grouping__id, count(distinct cust_id) from dataset group by A,B,C with cube 3. roll up select A,B,C, grouping__id, count(distinct cust_id) from dataset group by A..
2022.05.01 -
정규표현식 예제
https://blogpack.tistory.com/560 복사해서 바로 사용하는 자주 사용하는 정규표현식(Regular Expression) Top 20 1. 영문자 소문자, 숫자, "-", "_" 로만 구성된 길이 2 ~ 10자리 사이 문자열 /^[a-z0-9_-]{2,10}$/ 2. 신용카드 번호 19자리 숫자와 "-": /^[0-9-]{19}$/ 4-4-4-4 체크: /^[0-9]{4}[-\s\.]?[0-9]{4}[-\s\.]?[0-9.. blogpack.tistory.com https://codingspooning.tistory.com/entry/MySQL-정규표현식-검색하기-REGEXP-LIKE
2022.01.06