SQL de CASE — WHEN kullanımı

Belirli koşullara göre bir sütunda yer almasını istediğimiz değeri getirmek.

SELECT IASPURINF.[DOCUMENT], IASPURINF.COMPANY, IASPURINF.PLANT, IASPURINF.MATERIAL, IASPURINF.VENDOR, IASPURINF.BUSAREA, IASPURINF.VALIDFROM,
IASPURINF.VALIDUNTIL, IASPURINF.PURDEPT, IASPURINF.NET, IASPURINF.PUNIT, IASPURINF.CURRENCY, IASPURINF.PURUNIT, IASPURINF.STEXT,
IASPURINF.DELIVERYDAY, IASPURINF.MINORDER, IASPURINF.VMATERIAL, IASCUSTOMER.NAME1
,V.EXCHRATESAL
,CASE WHEN IASPURINF.CURRENCY =’TL’ THEN IASPURINF.NET ELSE IASPURINF.NET * V.EXCHRATESAL END AS FTL
FROM IASCUSTOMER INNER JOIN
IASPURINF ON IASCUSTOMER.CLIENT = IASPURINF.CLIENT AND IASCUSTOMER.COMPANY = IASPURINF.COMPANY AND
IASCUSTOMER.CUSTOMER = IASPURINF.VENDOR AND IASCUSTOMER.BUSAREA = IASPURINF.BUSAREA LEFT OUTER JOIN
VW_IAS_KUR AS V ON IASPURINF.CURRENCY = V.CURRENCY
WHERE (IASPURINF.CLIENT = ’00′) AND (IASPURINF.COMPANY LIKE ’01′) AND (IASPURINF.PLANT LIKE ‘%’) AND (IASPURINF.VENDOR LIKE ‘%’) AND
(IASPURINF.MATERIAL LIKE ‘WU17X13′) AND (IASPURINF.BUSAREA LIKE ‘%’) AND (IASPURINF.[DOCUMENT] = 4) AND (IASPURINF.ITEMNUM = 1) AND
(IASCUSTOMER.ISCUSTORVEND >= 2) AND (IASPURINF.STEXT LIKE ‘%’) AND (IASCUSTOMER.NAME1 LIKE ‘%’) AND (IASPURINF.PURDEPT LIKE ‘%’) AND
(IASPURINF.VALIDFROM <= GETDATE()) AND (IASPURINF.VALIDUNTIL >= GETDATE()) AND (IASPURINF.ISDELETE = 0)
ORDER BY IASPURINF.COMPANY, IASPURINF.PLANT, IASPURINF.MATERIAL, IASPURINF.VENDOR, IASPURINF.BUSAREA

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.