	CREATE
	VIEW VIEW_SPED_C390
	AS
	(
	select
		NF2D.CST, 
		NF2D.CFOP, 
		NF2D.TAXA_ICMS, 
		NF2C.DATA_EMISSAO,
		SUM(NF2D.VALOR_TOTAL) AS SOMA_ITEM, 
		SUM(NF2D.BASE_ICMS) AS SOMA_BASE_ICMS, 
		SUM(NF2D.ICMS) AS SOMA_ICMS, 
		SUM(NF2D.ICMS_OUTRAS) AS SOMA_ICMS_OUTRAS 
	from 
		ECF_NOTA_FISCAL_DETALHE NF2D, ECF_NOTA_FISCAL_CABECALHO NF2C 
	where 
		NF2D.ID_NF_CABECALHO = NF2C.ID
	group by 
		CST, CFOP, TAXA_ICMS
	)