SELECT CASE WHEN
(SELECT ISDATE(b.tarih)) = 0 THEN CAST(b.tarih AS DATETIME) ELSE NULL END AS Tarihim, KartNo
FROM Depo AS b
GROUP BY Tarih, KartNo
ORDER BY Tarih DESC
(SELECT ISDATE(b.tarih)) = 0 THEN CAST(b.tarih AS DATETIME) ELSE NULL END AS Tarihim, KartNo
FROM Depo AS b
GROUP BY Tarih, KartNo
ORDER BY Tarih DESC