I'm making a report, where I need to follow the following layout:
Withthequerybelow,youhavecreatedmorerows,ratherthangroupingemployeesbycompany:
selecte.cnpjascnpj,e.nome_completoasempresa,li.codassolicitacao,''funcionariosfromliberacoesli,empresaewhereli.cnpj=e.cnpjandli.dt_acesso_ini=curdate()unionallselect''ascnpj,''asempresa,''assolicitacao,f.nome_completoasfuncionariofromfuncionariosf,empresaewheref.cnpj=e.cnpjorderby1desc;
Bringingmethisresult:
Inaquery,canIjustmaketheoutputlayoutlooklikeIneedtofollow?
UPDATE
Itriedthequerybelow,buttheresultisstilloutofthewayIneed:
selectli.cod,e.cnpj,e.nome_completoasempresa,coalesce(f.nome_completo,'X')asfuncionariofromempresaeleftouterjoinfuncionariosfonf.cnpj=e.cnpjleftouterjoinliberacoeslionli.cnpj=e.cnpj
Result: