Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
select taxvalue, max(convert(varchar,choosed_date,103)) as Recent_Date from taxdetails group by taxvalue

i tried above coding to get taxvalue using most recent date but i am getting output like


Taxvalue Recent_Date

11 22/09/2012
12 23/09/2012
13 24/09/2012
Posted
Comments
[no name] 21-Sep-12 6:49am    
Max(datefield)

WHy you are using group by?

SQL
select * from taxdetails WHERE convert(varchar,choosed_date,103)=(select max(varchar,choosed_date,103)  from taxdetails)


[Edited]
Added WHERE keyword in the statement(was missing).
 
Share this answer
 
v3
If you want o/p like below
Taxvalue   Recent_Date
----------------------
13         24/09/2012

then,
SQL
select taxvalue, max(convert(varchar,choosed_date,103)) as Recent_Date from taxdetails where Choosed_date= (select max(Choosed_date) from taxdetails) 

Happy Coding!
:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900