Click here to Skip to main content
16,011,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hye everybody,

I have a data REGCOUNT_T
--------------------------
1
10
2
3
4
5
6
7
8
9

This is my SQL command:
SELECT MAX(REGCOUNT_T) AS RUNCOUNT FROM FEEDBACK_DATA

After next execution, I still get 9 as the max value. How to get the 10 value so that the next running count will be 11 after I add by 1?
Posted
Updated 16-May-12 14:59pm
v2

1 solution

The reason is that the data of REGCOUNT_T column may be in text type, in which case 10 comes before 9, so 9 is returned as maximum value.
To get the correct result either convert the value of REGCOUNT_T to numeric type as below
SQL
SELECT MAX(CONVERT(INT,REGCOUNT_T)) AS RUNCOUNT FROM FEEDBACK_DATA

or set the data type REGCOUNT_T to a numeric type like INT.
 
Share this answer
 
Comments
snamyna 16-May-12 21:21pm    
OK.. TQ so much.! :)
VJ Reddy 16-May-12 22:15pm    
You're welcome and thank you for accepting the solution :)
Sandeep Mewara 17-May-12 1:07am    
My 5!
VJ Reddy 17-May-12 1:13am    
Thank you, Sandeep :)

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