cancel
Showing results for 
Search instead for 
Did you mean: 

Sum or average of values in VARCHAR column

Former Member
0 Kudos

Hi,

I have entries in a VARCHAR column like this:

00:00:00.2808005

00:00:00.3130006

How can I perform a SUM or get the AVG or the like?

I have tried to CAST/CONVERT it to an integer, decimal but no luck.

Any ideas?

Thanks in advance,

G

Accepted Solutions (0)

Answers (1)

Answers (1)

lbreddemann
Active Contributor
0 Kudos

Hi Gavan,

well both strings don't look like numbers.

The look like hours:minutes:seconds.splitseconds to me, but I'm just guessing here.

If always the digits after the decimal point are relevant, you can use SAP HANA Reference: SUBSTRING before the cast to another data type.

Once the data has been converted to a numeric type, numeric functions like AVG and SUM will work.

- Lars

Former Member
0 Kudos

Hi Lars,

You are the man!

Thank you,

Gavan