Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- Pessoa.NomePessoa as GarcomAtd,
- Atendimento.NumeroMesa,
- Cardapio.NomeItem,
- AtendimentoItem.Quantidade,
- AtendimentoItem.ValorItem,
- AtendimentoItem.ValorTotal,
- AtendimentoInterno.DataHoraAtendimento,
- pes.NomePessoa as GarcomAtdIterno,
- CASE
- WHEN bar.IdAtendimentoItem IS NULL THEN 'COZINHA'
- ELSE 'BAR'
- END as LocalAtendimentoInterno
- FROM Atendimento
- INNER JOIN Pessoa on Atendimento.IdPessoa = Pessoa.IdPessoa
- INNER JOIN AtendimentoItem on AtendimentoItem.IdAtendimento = Atendimento.IdAtendimento
- INNER JOIN Cardapio on Cardapio.IdCardapio = AtendimentoItem.IdCardapio
- INNER JOIN AtendimentoInterno on AtendimentoInterno.IdAtendimentoItem = AtendimentoItem.IdAtendimentoItem
- LEFT JOIN Pessoa as pes on pes.IdPessoa = AtendimentoInterno.IdPessoa
- LEFT JOIN AtendimentoInternoBar as bar on bar.IdAtendimentoItem = AtendimentoInterno.IdAtendimentoItem
- LEFT JOIN AtendimentoInternoCozinha as cozinha on cozinha.IdAtendimentoItem = AtendimentoInterno.IdAtendimentoItem
- WHERE Pessoa.NomePessoa like '%a%' AND NumeroMesa in(1,2,3,4,5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement