Hi

Order by with conition

select Employee.CompanyID, Empl.EmployeeID , Gender, Email, FirstName, LastName,  
                 FirstName+' '+LastName as 'Name',  
  PhotoPath,dbo.fnFormatDate(DOB,'dd Mon') As 'DateDisplay',    
  dbo.fnFormatDate(DOB,'dd Mon')  
--+' ('+(Convert(Varchar(5),(Datediff(yy,DOB, GetDate()))) + ' yrs')+')'  
  As 'Value',DOB  
 FROM Emp_tb_eob_Personal Empl  
  inner join Emp_tb_Employee Employee on Employee.EmployeeID = Empl.EmployeeID  
   cross join dbo.GetDays(Getdate(),Getdate()+30) as dates where weekofmonthnumber>0  
 and month(dates.date)=month(DOB) and day(dates.date)=day(DOB) and  
   AccountStatus=1 and (CompanyID=@companyid or @companyid=0) order by case when month(dob)=12 or month(dob)=1
   then month(dob) End desc,day(dob) asc
Previous
Next Post »