Hi @everyone,
I have a sql table with 2 columns namely ReqNo and Sr.No of type bigint and varchar as in below an example and query. I am trying to get the maximum value of the column Sr.No wrt ReqNo but I am, getting wrong value. Kindly suggest me to correct the query.
Request No
|
Sr.No
|
120184
|
1
|
120184
|
1.1
|
120184
|
1.10
|
120184
|
1.2
|
120184
|
1.3
|
120184
|
1.4
|
120184
|
1.5
|
120184
|
1.6
|
120184
|
1.7
|
120184
|
1.8
|
120184
|
1.9
|
Query
select MAX(cast(SrNo as float)) as SrNo from tbl_Material_Req where Req_No='120184' AND BudgInvNo = '17246'
The above query returns 1.9 as max value. But the table above has 1.10 which is greater than 1.9
What I have tried
MAX(cast(SrNo as decimal(10,2)))
But doesn’t work for me.
Any suggestion will be appreciated.