---
title: "Get max value in access or sql"  
description: "Get max value in access or sql"  
author: "Manmohan Jha"  
published: 2014-04-15  
updated: 2014-04-29  
canonical: https://www.mindstick.com/forum/2018/get-max-value-in-access-or-sql  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Get max value in access or sql

How to get [Max value](https://www.mindstick.com/forum/159367/sql-to-calculate-number-of-values-for-each-day-based-on-a-max-value-from-previous-date) in [Access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) or sql...???\
\
[column Name](https://www.mindstick.com/forum/369/how-can-i-add-a-column-name-to-my-grid) :- receipt_nocolumn [datatype](https://www.mindstick.com/forum/160266/explain-the-datatype-data-annotation-and-its-significance-in-data-entry-and-display) :- nvarchar\
receipt_no value is 1 to 1945\
I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) but [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) is wrong...every time return 999(because 9 is grater than 0 to 9 for ascii reason )...\
Thanks & regardsManmohan Jha

## Replies

### Reply by Manmohan Jha

I've solved this myself...\
\
Access Query is :- SELECT Max(Val(receipt_no)) AS rcptno FROM Receipt

### Reply by Manmohan Jha

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???/

### Reply by Chris Anderson

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


---

Original Source: https://www.mindstick.com/forum/2018/get-max-value-in-access-or-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
