'2019/09/23'에 해당되는 글 4건

  1. 2019.09.23 string_agg() + COALESCE() + DISTINCT
  2. 2019.09.23 해피빈 기부 2
  3. 2019.09.23 screen 명령어와 함께 실행하기
  4. 2019.09.23 screen 스크롤하기

아래와 같이 하면 값이 없는 애는 NULL로 표기된채로 ,로 여러개 쭈르르르륵 나온다.

NULL을 해주는 이유는 NULL일 경우 값을 아예 생략해서 몇개의 값을 합친건지 알수가 없기 때문.

어떻게 보면.. DB를 DB답게 안쓰는 방법인데

여러개의 레코드를 합치다 보면 NULL의 위치가 서로 다를테니 형식을 맞추기 위함이라고 해야하려나?

 

string_agg(COALESCE(합칠변수::text,'NULL'), ',')

---

 

ms sql server 에서는 isnull로 값없는건 빠지지 않도록 해주어야 한다고..

[링크 : https://docs.microsoft.com/ko-kr/sql/t-sql/functions/string-agg-transact-sql?view=sql-server-2017]

[링크 : https://xshine.tistory.com/205]

[링크 : https://dbrang.tistory.com/1289]

 

COALESCE() 라는 함수를 지원한다고.

[링크 : http://www.postgresqltutorial.com/postgresql-isnull/]

 

The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example:

This returns description if it is not null, otherwise short_description if it is not null, otherwise (none).

Like a CASE expression, COALESCE only evaluates the arguments that are needed to determine the result; that is, arguments to the right of the first non-null argument are not evaluated. This SQL-standard function provides capabilities similar to NVL and IFNULL, which are used in some other database systems.

[링크 : https://www.postgresql.org/docs/9.5/functions-conditional.html]

 

[링크 : https://stackoverflow.com/.../how-to-concatenate-strings-of-a-string-field-in-a-postgresql-group-by-query]

[링크 : https://blog.gaerae.com/2015/09/postgresql-multiple-rows-and-json-or-string.html]

 

2019/09/08 - [프로그램 사용/postgreSQL] - sql 여러행을 하나로 합치기 concat

 

+

json_agg(expr) 은 delimiter 없이 JSON ARRAY 타입으로 리턴해준다.

json_agg는 string_agg와는 다르게 null을 기본으로 출력해준다.

 

+

DISTINCT를 string_arr 안에서 사용이 가능하다.

[링크 : https://yahwang.github.io/posts/46]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql transaction begin / commit / rollback  (0) 2019.09.24
sql 문 계산하기  (0) 2019.09.24
join where와 on  (0) 2019.09.18
복수 컬럼에 대한 inner join  (0) 2019.09.18
postgresql update  (0) 2019.09.18
Posted by 구차니
개소리 왈왈/블로그2019. 9. 23. 12:35

이번달에 2개 만료 된다길래

후다닥 기부

 

작년에는 그래도 어린이집 카페 글 올리고 그래서 좀 받았는데 올해는 미미하네?

정말로 이 금액이 기부되는진 모르겠지만

가끔 카페 광고 눌러서 받는 콩으로 누군가가 조금은 더 따스해지는 한해가 되길..

Posted by 구차니
Linux2019. 9. 23. 06:57

-S로 스크린에 이름을 주고

-r -X 옵션으로 명령을 준다.

screen -S "mylittlescreen" -d -m
screen -r "mylittlescreen" -X stuff $'ls\n'

 

[링크 : https://stackoverflow.com/questions/7049252/how-to-create-a-screen-executing-given-command]

'Linux' 카테고리의 다른 글

서비스 등록 오류  (0) 2019.10.10
grep -o 매칭되는 영역만 출력하기  (0) 2019.09.25
screen 스크롤하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
awk csv  (0) 2019.09.05
Posted by 구차니
Linux2019. 9. 23. 06:56

우오오 이런 좋은 기능이?

ctrl-a-esc

pgup/pgdn

esc

 

[링크 : https://medium.com/@erwinousy/screen-command-사용법-linux-mac-62bf5dd23110

'Linux' 카테고리의 다른 글

grep -o 매칭되는 영역만 출력하기  (0) 2019.09.25
screen 명령어와 함께 실행하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
awk csv  (0) 2019.09.05
awk 변수 지정  (0) 2019.09.02
Posted by 구차니