cancel
Showing results for 
Search instead for 
Did you mean: 

Some info about Query..

Former Member
0 Kudos

Hi.. See the image..

I had created one table in sap b1

it has some values ... some 45 ,34,23,

so

i had written a query as

select max(code) from [sales_oppr]

But, it is showing diff values instead of max value may i know why..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

   Try this....

    Select max(cast("code" as numeric)) from [@sales_oppor]

Rgds,

Priya

Answers (4)

Answers (4)

Rafaee_Mustafa
Active Contributor
0 Kudos

Hi Seenu,

By default UDT created 2 fields Code and Name of nvarchar field type. Convert your field to INT

Try

SELECT MAX(CAST(Code AS Int)) FROM @sale

Regards,

KennedyT21
Active Contributor
0 Kudos

Hi Seenu,

What is the Filed Type for Code... it should be Int as for your required result. I think now it is nvarchar...

try this

SELECT ISNULL(MAX(CAST( code  AS Numeric)),0) FROM  [sales_oppr]

Regards

Kennedy

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Seenu,

Try this

SELECT ISNULL(MAX(CAST(" + Column + " AS Numeric)),0) FROM [" + Table + "]

Hope it helps...

Thanks

KennedyT21
Active Contributor
0 Kudos

Hi Seenu ,

I think the data has some error... check with the Data

your Query is correct

Regards

Kennedy