I want to apply various cases on my query according to functionality.
There is a SQL query given below, that query performs DateDIff operation by slecting max and min date according to Card ar you can say id,here' the query
SELECT Count(DATEDIFF(D, MinDate, MaxDate)/30) AS DIFF FROM ( SELECT MAX(TDate) AS MaxDate, MIN(TDate) AS MinDate FROM EDATA GROUP BY TCard )a Group by DATEDIFF(D, MinDate, MaxDate)/30
Now i want to apply some kind of sorting in this query before performing DateDiff operation (sorting can be based on several parameters like age, name etc. but 1 at a time according to the cases)
Now I want to know How to apply cases over this query an where?