SELECT FLOOR(2 + RAND()*3)

SELECT question_id as question_id,
create_time as start_time,
3 as term,
DATE_ADD(create_time,INTERVAL FLOOR(2 + RAND()*3) MONTH) as end_time,
IF(problem_type = 'A',1,0) as point_someone,
IF(problem_type = 'E',1,0) as point_something,
FLOOR(0.5 + RAND()) as analogy,
FLOOR(0.5 + RAND()) as establishment,
null as implementation
from ods_question_csix;

create table dw_factor01 as (SELECT * from dw_factor where id = 100000);


INSERT into dw_factor01 (question_id,start_time,term,end_time,point_someone,point_something,analogy,establishment,implementation)(
SELECT question_id as question_id,
create_time as start_time,
3 as term,
DATE_ADD(create_time,INTERVAL FLOOR(2 + RAND()*3) MONTH) as end_time,
IF(problem_type = 'A',1,0) as point_someone,
IF(problem_type = 'E',1,0) as point_something,
FLOOR(0.5 + RAND()) as analogy,
FLOOR(0.5 + RAND()) as establishment,
null as implementation
from ods_question_csix
);

SELECT question_id as question_id,start_time as start_time,term as term,end_time as end_time,point_someone as point_someone,
point_something as point_something,analogy as analogy,establishment as establishment,
IF(establishment = 1,FLOOR(0.5 + RAND()),0) as implementation from dw_factor01 ;

create table dw_factor02 as (SELECT * from dw_factor01 where id = 100000);

INSERT into dw_factor02 (question_id,start_time,term,end_time,point_someone,point_something,analogy,establishment,implementation)(
SELECT question_id as question_id,start_time as start_time,term as term,end_time as end_time,point_someone as point_someone,
point_something as point_something,analogy as analogy,establishment as establishment,
IF(establishment = 1,FLOOR(0.5 + RAND()),0) as implementation from dw_factor01
);

posted on 2020-09-07 17:14  洋槐  阅读(326)  评论(0)    收藏  举报