SQL
メインテーブルに関連付くサブテーブルのうち サブのIDが最大の情報を取ってくる場合のSQL select a.*,c.* from main_table a inner join ( select main_id,max(sub_id) sub_id from sub_table group by main_id ) b on a.main_id = b.main_id inner join su…
update_col1 = case when tbl1.datecolumn <= '20210101' then tbl1.value1 else tbl1.value2 end
検証はSQLiteでやっているので他の環境でも使えるかとテーブル作成 CREATE TABLE "subtable" ( "date1" TEXT, "date2" TEXT, "date3" TEXT, "flg" TEXT ); CREATE TABLE "maintable" ( "dateval" TEXT, "value" TEXT );データ投入 insert into subtable ('da…
.outputでファイル名指定 .output output_file.txt select some_text from some_table;
.tables
configureでパスを指定してインストール(足りないものがあれば適宜brew) 他のUNIXならだいたい同じかと ./configure --prefix=/Users/user/Desktop/postgresinstall make make install initdbを実行してからpostgresを起動 cd /Users/user/Desktop/postgre…