이전일 결과를 현재일의 값으로 넣는 SQL

This topic contains 0 replies, has 1 voice, and was last updated by  technote 2017-10-17 19:35.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #128

    technote
    Keymaster

    update individual_data a left join (select code, date, end_price, (select z.end_price from individual_data z where z.code = y.code and z.date < y.date order by z.date desc limit 1) as yesterday_price from individual_data y) b on a.code = b.code and a.date = b.date and a.end_price = b.end_price set a.yesterday_price = b.yesterday_price, a.diff_price = a.end_price-b.yesterday_price, a.diff_percent = (a.end_price-b.yesterday_price)*100/b.yesterday_price

    update individual_data a left join (select code, date, end_price, (select z.end_price from individual_data z where z.code = y.code and z.date < y.date order by z.date desc limit 1) as yesterday_price from individual_data y) b on a.code = b.code and a.date = b.date and a.end_price = b.end_price set a.diff_price = a.end_price-b.yesterday_price, a.diff_percent = (a.end_price-b.yesterday_price)*100/b.yesterday_price;

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.