Skip to content

Instantly share code, notes, and snippets.

@muripoLife
Created February 13, 2020 04:00
Show Gist options
  • Save muripoLife/edf4cc3407327c87b60c150d91a5f0be to your computer and use it in GitHub Desktop.
Save muripoLife/edf4cc3407327c87b60c150d91a5f0be to your computer and use it in GitHub Desktop.
MySQLで直積を書く(月とidの直積)
yyyymm
2019-01-01
2019-02-01
2019-03-01
2019-04-01
2019-05-01
id
1
2
3
4
5
with temp_yyyymm as(
select left(date, 7) yyyymm from calendar group by 1
),
temp_id as(
select id from table
)
select
id,
yyyymm
from temp_id, temp_yyyymm
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment