Home > DeveloperSection > Forums > Get max value in access or sql
Manmohan Jha

Total Post:35

Posted on    April-15-2014 8:52 AM

 C# C# 

 3 Reply(s)
 1857  View(s)
Rate this:
How to get Max value in Access or sql...???

column Name     :- receipt_no
column datatype :- nvarchar

receipt_no value is 1 to 1945

I am trying but result is wrong...
every time return 999(because 9 is grater than 0 to 9 for ascii reason )...

Thanks & regards
Manmohan Jha

Chris Anderson
Chris Anderson

Total Post:65

Posted on    April-16-2014 1:02 AM

You need to convert your nvarchar datatype to int before calling max function. The working query given below:

Select max(Convert(int,receipt_no)) From Receipt

Manmohan Jha

Total Post:35

Posted on    April-16-2014 2:21 AM

I use this query multiple time, but not work in access
i also use:-
Select max(Cast(receipt_no as int)) From Receipt

Both not working in access db

Modified On Apr-16-2014 07:32:25 AM

Manmohan Jha

Total Post:35

Posted on    April-29-2014 10:24 PM

I've solved this myself...

Access Query is :- SELECT Max(Val(receipt_no)) AS rcptno FROM Receipt

Don't want to miss updates? Please click the below button!

Follow MindStick