GET MAX VALUE IN ACCESS OR SQL

Manmohan Jha

Total Post:35

Points:245
Posted by  Manmohan Jha
C# 
C#
 2153  View(s)
Ratings:
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
  1. Chris Anderson

    Post:65

    Points:455
    Re: Get max value in access or sql

    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

  1. Manmohan Jha

    Post:35

    Points:245
    Re: Get max value in access or sql

    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
    Why???/

      Modified On Apr-16-2014 07:32:25 AM
  1. Manmohan Jha

    Post:35

    Points:245
    Re: Get max value in access or sql

    I've solved this myself...

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!