鼎鼎知识库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2021.2.3好用的sql语句.md 1.8KB

3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
123456789101112131415161718192021222324252627282930
  1. ```
  2. BEGIN
  3. SELECT SUM(power),yyyymmdd FROM powers WHERE monthweekday="HOURS" AND StartTime<=STR_TO_DATE(yyyymmdd,'%Y%m%d%H') AND EndTime>=STR_TO_DATE(yyyymmdd,'%Y%m%d%H') GROUP BY yyyymmdd;
  4. END
  5. ```
  6. ```
  7. select count(*) from breakerdatas where mac='98CC4D213004'
  8. select count(*) from breakerdatas where mac='187ED53338C4'
  9. select count(*) from breakerdatas where mac='187ED53159E4'
  10. select count(*) from breakerdatas where mac='98CC4D213003'
  11. delete from breakerdatas where mac='187ED53338C4' and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') <= str_to_date('2021-02-23 18:54:00', '%Y-%m-%d %H:%i:%s')
  12. select CreateTime, mac, addr from breakerdatas where mac='187ED53338C4' and addr='1' and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') >= str_to_date('2021-02-23 19:30:00', '%Y-%m-%d %H:%i:%s')
  13. select * from breakerdatas where mac='187ED53338C4' and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') >= str_to_date('2021-02-23 19:30:00', '%Y-%m-%d %H:%i:%s')
  14. select * from breakerdatas where mac='187ED53338C4' and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') >= date_sub(now(), interval 1 hour)
  15. select mac, addr, CreateTime from breakerdatas where mac='187ED53338C4' and addr='1' ORDER BY CreateTime desc
  16. select count(*) from breakerdatas where mac='187ED53338C4' and addr='1'
  17. select str_to_date(CreateTime, '%Y-%m-%d %H:%i') as dt, mac, addr, A_WP from breakerdatas where mac in ('98CC4D213004','187ED5333333') and addr in ('1','2') and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') >= str_to_date('2021-03-19 14:00:00', '%Y-%m-%d %H:%i:%s')
  18. select str_to_date(CreateTime, '%Y-%m-%d %H:%i') as dt,sum(A_WP) as wp from breakerdatas where mac in ('98CC4D213004','187ED5333333') and addr in ('1','2') and str_to_date(CreateTime, '%Y-%m-%d %H:%i:%s') >= str_to_date('2021-03-19 14:00:00', '%Y-%m-%d %H:%i:%s') group by dt
  19. ```