$1 View [dbo].[OdemeTipi_Yuzde]
as
SELECT
		CASE
			WHEN ISNULL(odm_tip,'') = 0 THEN 'NAKİT'
			WHEN ISNULL(odm_tip,'') = 1 THEN 'KREDİ'
			WHEN ISNULL(odm_tip,'') = 2 THEN 'AÇIK HESAP'
		END AS [Tip],
		(SUM(CASE WHEN evr_belge_tur in (1,2) THEN evr_yekun ELSE 0 END))-(SUM(CASE WHEN evr_belge_tur in (3) THEN evr_yekun ELSE 0 END)) as [Tutar]
FROM
		EVRAK_UST_BILGI WITH(NOLOCK)
LEFT OUTER JOIN EVRAK_ODEME_BILGI  WITH(NOLOCK) on odmhar_evrak_rec_id = evr_RECno
LEFT OUTER JOIN ODEME_TIPLERI WITH(NOLOCK) on odm_kod = odmhar_odeme_kod and odm_magazano= evr_magaza_kod


WHERE 
		evr_belge_tur in (1,2,3)
group by 
		odm_tip