Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. WITH DetalhesEventos AS (
  2.  
  3. select f.id as IdEvento,
  4. f.data_inicial as DataInicial,
  5. g.codigo_evento as CodigoEveto,
  6. g.descricao as DescricaoEvento,
  7. h.descricao as SolicitanteEventoParada,
  8. f.observacao as Observacao
  9. from composicao as a
  10. join evento as f on a.id = f.id_composicao
  11. join evento_descricao as g on f.id_evento_descricao = g.id
  12. left join evento_parada as h on f.id_evento_parada = h.id
  13. where ( cast(a.data_inicio as date) between cast('2019-05-25' as date) and cast('2019-05-25' as date) )
  14. and g.codigo_evento = 'P'
  15. and a.id = '3561'
  16.  
  17.  
  18. union all
  19.  
  20. select b.data_inicial as DataFinal
  21. from DetalhesEventos as a
  22. join evento as b on a.IdEvento = b.id
  23. where b.id = a.IdEvento + 1
  24. )
  25. SELECT * from DetalhesEventos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement