|
|
select
|
|
|
A.productId,
|
|
|
sum(`2019-03-01`) AS '2019-03-01',
|
|
|
sum(`2019-03-02`) AS '2019-03-02',
|
|
|
sum(`2019-03-03`) AS '2019-03-03',
|
|
|
sum(`2019-03-04`) AS '2019-03-04',
|
|
|
sum(`2019-03-05`) AS '2019-03-05',
|
|
|
sum(`2019-03-06`) AS '2019-03-06',
|
|
|
sum(`2019-03-07`) AS '2019-03-07',
|
|
|
sum(`2019-03-08`) AS '2019-03-08',
|
|
|
sum(`2019-03-09`) AS '2019-03-09',
|
|
|
sum(`2019-03-10`) AS '2019-03-10',
|
|
|
sum(`2019-03-11`) AS '2019-03-11',
|
|
|
sum(`2019-03-12`) AS '2019-03-12',
|
|
|
sum(`2019-03-13`) AS '2019-03-13',
|
|
|
sum(`2019-03-14`) AS '2019-03-14',
|
|
|
sum(`2019-03-15`) AS '2019-03-15',
|
|
|
sum(`2019-03-16`) AS '2019-03-16',
|
|
|
sum(`2019-03-17`) AS '2019-03-17',
|
|
|
sum(`2019-03-18`) AS '2019-03-18',
|
|
|
sum(`2019-03-19`) AS '2019-03-19',
|
|
|
sum(`2019-03-20`) AS '2019-03-20',
|
|
|
sum(`2019-03-21`) AS '2019-03-21',
|
|
|
sum(`2019-03-22`) AS '2019-03-22',
|
|
|
sum(`2019-03-23`) AS '2019-03-23',
|
|
|
sum(`2019-03-24`) AS '2019-03-24',
|
|
|
sum(`2019-03-25`) AS '2019-03-25',
|
|
|
sum(`2019-03-26`) AS '2019-03-26',
|
|
|
sum(`2019-03-27`) AS '2019-03-27',
|
|
|
sum(`2019-03-28`) AS '2019-03-28',
|
|
|
sum(`2019-03-29`) AS '2019-03-29',
|
|
|
sum(`2019-03-30`) AS '2019-03-30',
|
|
|
sum(`2019-03-31`) AS '2019-03-31'
|
|
|
b.id,
|
|
|
b.model,
|
|
|
b.price,
|
|
|
IFNULL(sum(`2019-04-01`), 0) AS '2019-04-01',
|
|
|
IFNULL(sum(`2019-04-02`), 0) AS '2019-04-02',
|
|
|
IFNULL(sum(`2019-04-03`), 0) AS '2019-04-03',
|
|
|
IFNULL(sum(`2019-04-04`), 0) AS '2019-04-04',
|
|
|
IFNULL(sum(`2019-04-05`), 0) AS '2019-04-05',
|
|
|
IFNULL(sum(`2019-04-06`), 0) AS '2019-04-06',
|
|
|
IFNULL(sum(`2019-04-07`), 0) AS '2019-04-07',
|
|
|
IFNULL(sum(`2019-04-08`), 0) AS '2019-04-08',
|
|
|
IFNULL(sum(`2019-04-09`), 0) AS '2019-04-09',
|
|
|
IFNULL(sum(`2019-04-10`), 0) AS '2019-04-10',
|
|
|
IFNULL(sum(`2019-04-11`), 0) AS '2019-04-11',
|
|
|
IFNULL(sum(`2019-04-12`), 0) AS '2019-04-12',
|
|
|
IFNULL(sum(`2019-04-13`), 0) AS '2019-04-13',
|
|
|
IFNULL(sum(`2019-04-14`), 0) AS '2019-04-14',
|
|
|
IFNULL(sum(`2019-04-15`), 0) AS '2019-04-15',
|
|
|
IFNULL(sum(`2019-04-16`), 0) AS '2019-04-16',
|
|
|
IFNULL(sum(`2019-04-17`), 0) AS '2019-04-17',
|
|
|
IFNULL(sum(`2019-04-18`), 0) AS '2019-04-18',
|
|
|
IFNULL(sum(`2019-04-19`), 0) AS '2019-04-19',
|
|
|
IFNULL(sum(`2019-04-20`), 0) AS '2019-04-20',
|
|
|
IFNULL(sum(`2019-04-21`), 0) AS '2019-04-21',
|
|
|
IFNULL(sum(`2019-04-22`), 0) AS '2019-04-22',
|
|
|
IFNULL(sum(`2019-04-23`), 0) AS '2019-04-23',
|
|
|
IFNULL(sum(`2019-04-24`), 0) AS '2019-04-24',
|
|
|
IFNULL(sum(`2019-04-25`), 0) AS '2019-04-25',
|
|
|
IFNULL(sum(`2019-04-26`), 0) AS '2019-04-26',
|
|
|
IFNULL(sum(`2019-04-27`), 0) AS '2019-04-27',
|
|
|
IFNULL(sum(`2019-04-28`), 0) AS '2019-04-28',
|
|
|
IFNULL(sum(`2019-04-29`), 0) AS '2019-04-29',
|
|
|
IFNULL(sum(`2019-04-30`), 0) AS '2019-04-30'
|
|
|
from
|
|
|
sknprice b
|
|
|
left join
|
|
|
(
|
|
|
select
|
|
|
productId,
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-01' then 1 else 0 end as '2019-03-01',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-02' then 1 else 0 end as '2019-03-02',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-03' then 1 else 0 end as '2019-03-03',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-04' then 1 else 0 end as '2019-03-04',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-05' then 1 else 0 end as '2019-03-05',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-06' then 1 else 0 end as '2019-03-06',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-07' then 1 else 0 end as '2019-03-07',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-08' then 1 else 0 end as '2019-03-08',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-09' then 1 else 0 end as '2019-03-09',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-10' then 1 else 0 end as '2019-03-10',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-11' then 1 else 0 end as '2019-03-11',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-12' then 1 else 0 end as '2019-03-12',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-13' then 1 else 0 end as '2019-03-13',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-14' then 1 else 0 end as '2019-03-14',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-15' then 1 else 0 end as '2019-03-15',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-16' then 1 else 0 end as '2019-03-16',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-17' then 1 else 0 end as '2019-03-17',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-18' then 1 else 0 end as '2019-03-18',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-19' then 1 else 0 end as '2019-03-19',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-20' then 1 else 0 end as '2019-03-20',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-21' then 1 else 0 end as '2019-03-21',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-22' then 1 else 0 end as '2019-03-22',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-23' then 1 else 0 end as '2019-03-23',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-24' then 1 else 0 end as '2019-03-24',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-25' then 1 else 0 end as '2019-03-25',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-26' then 1 else 0 end as '2019-03-26',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-27' then 1 else 0 end as '2019-03-27',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-28' then 1 else 0 end as '2019-03-28',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-29' then 1 else 0 end as '2019-03-29',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-30' then 1 else 0 end as '2019-03-30',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-03-31' then 1 else 0 end as '2019-03-31'
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-01' then b.price else 0 end as '2019-04-01',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-02' then b.price else 0 end as '2019-04-02',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-03' then b.price else 0 end as '2019-04-03',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-04' then b.price else 0 end as '2019-04-04',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-05' then b.price else 0 end as '2019-04-05',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-06' then b.price else 0 end as '2019-04-06',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-07' then b.price else 0 end as '2019-04-07',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-08' then b.price else 0 end as '2019-04-08',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-09' then b.price else 0 end as '2019-04-09',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-10' then b.price else 0 end as '2019-04-10',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-11' then b.price else 0 end as '2019-04-11',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-12' then b.price else 0 end as '2019-04-12',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-13' then b.price else 0 end as '2019-04-13',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-14' then b.price else 0 end as '2019-04-14',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-15' then b.price else 0 end as '2019-04-15',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-16' then b.price else 0 end as '2019-04-16',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-17' then b.price else 0 end as '2019-04-17',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-18' then b.price else 0 end as '2019-04-18',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-19' then b.price else 0 end as '2019-04-19',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-20' then b.price else 0 end as '2019-04-20',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-21' then b.price else 0 end as '2019-04-21',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-22' then b.price else 0 end as '2019-04-22',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-23' then b.price else 0 end as '2019-04-23',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-24' then b.price else 0 end as '2019-04-24',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-25' then b.price else 0 end as '2019-04-25',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-26' then b.price else 0 end as '2019-04-26',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-27' then b.price else 0 end as '2019-04-27',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-28' then b.price else 0 end as '2019-04-28',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-29' then b.price else 0 end as '2019-04-29',
|
|
|
case DATE_FORMAT(time,'%Y-%m-%d') when '2019-04-30' then b.price else 0 end as '2019-04-30'
|
|
|
from
|
|
|
buyers
|
|
|
buyers_2019_04 a left join sknprice b on a.productId = b.id
|
|
|
where
|
|
|
time >= '2019-03-01' and time < '2019-04-01'
|
|
|
) A
|
|
|
group by A.productId |
|
|
\ No newline at end of file |
|
|
time >= '2019-04-01' and time < '2019-05-01'
|
|
|
) A on A.productId = b.id
|
|
|
group by b.id,b.model,b.price |
|
|
\ No newline at end of file |
...
|
...
|
|