Created
March 29, 2014 12:29
-
-
Save roberto-filho/9853595 to your computer and use it in GitHub Desktop.
Query para buscar os lançamentos com data diferente da data da movimentação.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with q as ( | |
| select sum(case tipo | |
| when 'D' then valor | |
| else 0 | |
| end) debito, | |
| sum(case tipo | |
| when 'C' then valor | |
| else 0 | |
| end) credito, | |
| sum(valor) valor, | |
| lote, | |
| lcto.empresa_id, | |
| lcto.datalancamento::date | |
| from lancamentocontabil_lote lcto | |
| join planoconta cc on lcto.conta_id = cc.id | |
| where lcto.empresa_id = 225 | |
| group by lcto.empresa_id, | |
| lote, | |
| lcto.datalancamento::date | |
| ) | |
| select razao_social(empresa_id), lote, datalancamento, debito-credito diff | |
| from q | |
| where debito <> credito; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment