.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

find max number in database

Posted By: kamlesh     Posted Date: March 01, 2011    Points:2   Category :Sql Server
hi i have store some number and String in One Column with Varchar Datatype and i want query for finding Max Number in Database suppose my column name is account_num and table name is customer so how to do this

Please Help me

Kamlesh

Responses
Author: Pandian             
Posted Date: March 01, 2011     Points: 20   

Hi

CREATE TABLE Tb_Sample
(
Column1 VARCHAR(10)
)
Go

INSERT Tb_Sample VALUES('SQL')
INSERT Tb_Sample VALUES('123')
INSERT Tb_Sample VALUES('SERVER')
INSERT Tb_Sample VALUES('9')
INSERT Tb_Sample VALUES('10')
Go

SELECT MAX(CAST(Column1 AS INT)) [Max Value] FROM Tb_Sample
WHERE ISNUMERIC(Column1) =1
Go


Cheers
http://www.sqlserverbuddy.blogspot.com


If not I then who, If not now then when
Author: Maverick             
Posted Date: March 07, 2011     Points: 20   

Hello,

use

select (max(cast(<column> as int)) as maximum from sample

Hope this helps.

Thanks,
Maverick

Thanks,
Maverick
Author: sriram             
Posted Date: October 28, 2011     Points: 20   

Hi,

select max(empsalary) from employee

select (max(cast(empsalary)) from employee

hope this helps

Regards
Sriram.R
www.databaseresource.blogspot.com



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend