Untitled

mail@pastecode.io avatar
unknown
sql
2 years ago
887 B
1
Indexable
Never
select sum(`todostipos`.`valor`) as `total` from (select * from (select `codigo7` as `codigo`, `emissao7` as `emissao`, `vlrtotnot7` as `valor`, cast(serie7 as unsigned int) as `serie`, `subserie7` as `subSerie`, `stsnfe7` as `status`, `chvnfe7` as `chave`, 'nfe-emitida' as `modelo`, `datlan7` as `datlan`, `sql_rowid` as `sql_rowid` from `de1001` where `sr_deleted` <> ? union all (select `codigo7` as `codigo`, `data7` as `emissao`, null as `valor`, cast(serie7 as unsigned int) as `serie`, `subserie7` as `subSerie`, 'I' as `status`, `pronfe7` as `chave`, 'nfe-emitida' as `modelo`, `datlan7` as `datlan`, `sql_rowid` as `sql_rowid` from `de2801` where `sr_deleted` <> ? and `modelo7` = ? and `tipo7` = ?)) as `a` where `emissao` between ? and ?) as `todostipos` left join `downloads` on `todostipos`.`chave` = `downloads`.`chave` where `todostipos`.`status` not in (?, ?, ?) limit ?