我有一個這樣的科拉姆我的查詢與SQL Server 2008SQL Server 2008中:在列使用IF SQL查詢
CONVERT(VARCHAR(10),C.HACIZ_TAR,103) AS 'HACİZ TARİHİ'
在這個專欄中,一些數據值是01/01/1900
。
我想要的是,如果該列的值01/01/1900
,然後得到的null
代替01/01/1900
我怎樣才能做到這一點?
這是我的SQL全選擇部分
SELECT B.HESAP_NO, A.TEKLIF_NO1 + '/' + A.TEKLIF_NO2 AS 'TEKLIF',
B.MUS_K_ISIM, CONVERT(VARCHAR(10),A.ISL_TAR,103) AS 'TARIH',
SUM(ISNULL(CAST(A.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+
ISNULL(CAST(A.BSMV AS FLOAT),0)+ISNULL(CAST(A.GECIKME_FAIZ AS FLOAT),0)+
ISNULL(CAST(A.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN',
(CASE WHEN B.DOVIZ_KOD = 21 THEN 'EUR' WHEN B.DOVIZ_KOD = 2 THEN 'USD' WHEN B.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR',
D.AVUKAT, CONVERT(VARCHAR(10),C.ICRA_TAR,103) AS 'İCRA TARİHİ', CONVERT(VARCHAR(10),C.HACIZ_TAR,103) AS 'HACİZ TARİHİ'
@Konerak是的,你是對的,但我不知道如何使用CONVERT(VARCHAR(10)與Case When Then? – 2011-03-07 08:33:32
@Konerak http://msdn.microsoft.com/en-us/library/ms187928.aspx我使用它來格式化日期並由於某種原因保留它varchar。 – 2011-03-07 08:41:56
@Konerak是SQL Server。我忘了寫哪個服務器。我編輯帖子。 – 2011-03-07 08:48:19