Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[REFACTOR] 기수 필드 추가 #17

Open
kenu opened this issue Apr 26, 2021 · 1 comment
Open

[REFACTOR] 기수 필드 추가 #17

kenu opened this issue Apr 26, 2021 · 1 comment
Assignees

Comments

@kenu
Copy link
Contributor

kenu commented Apr 26, 2021

group

@kenu kenu changed the title 기수, 블랙홀 필드 추가 [REFACTOR] 기수 필드 추가 Apr 26, 2021
@kenu
Copy link
Contributor Author

kenu commented Apr 26, 2021

/* final batch */

update users as t1 join (
  select id,
  case
    when begin_at between '2020-01' and '2020-05' then 1
    when begin_at in ('2020-06', '2020-07') then 2
    when begin_at in ('2020-10', '2020-11', '2021-01') then 3
    else 4
  end as `grouped`
  from (
	select
	  id, username, substr(str_to_date(json_extract(data, '$.cursus_users[0].begin_at'),'"%Y-%m-%dT%T.%fZ"'), 1, 7) begin_at
	from users
	where str_to_date(json_extract(data, '$.cursus_users[1].begin_at'),'"%Y-%m-%dT%T.%fZ"') is not null
  ) aa
) as t2
using (id)
set t1.`group` = t2.`grouped`
where t1.`group` is null
;

select `group`, count(*) 
from users
group by `group`
;

@kenu kenu self-assigned this Apr 26, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant