##########################################################################
# VIEW - VW_NOTA_FATURADA
##########################################################################
-- SELECT
-- `c`.`CPF` AS `CPF`,
-- ROUND(SUM((`d`.`PRECO` * `d`.`QUANTIDADE`)), 2) AS `TOTAL_NOTAS`
-- FROM
-- (`notas_fiscais` `c`
-- JOIN `itens_notas_fiscais` `d` ON ((`c`.`NUMERO` = `d`.`NUMERO`)))
-- WHERE
-- (YEAR(`c`.`DATA_VENDA`) = 2016)
-- GROUP BY `c`.`CPF`
SELECT CONCAT("O cliente ",UCASE(A.NOME)," faturou R$ ",format(X.TOTAL_NOTAS,2,'de_DE'), " no ano de 2016") as RESULTADO
FROM TABELA_DE_CLIENTES A
RIGHT JOIN vw_NOTA_FATURADA X
ON A.CPF = X.CPF
ORDER BY A.NOME