Skip to content
Advertisement

Split SQL Server Column value

I have a SQL Server table which name is AbundanceImpact.

Monetary~50
Monetary~120
Monetary~200
Monetary~269.90
Monetary~125
Magnanimous~50
Monetary~22.05
Unlimited~500
Monetary~150
Monetary~300
Monetary~21.89
Monetary~10.95

So I want the all integer values only with SUM.

Advertisement

Answer

Try this below logic-

DEMO HERE

SELECT 
SUM(
    CAST(
        RIGHT(
            Column_name,
            LEN(Column_name) - CHARINDEX('~',Column_name,0)
        ) 
        AS FLOAT
    )
)
FROM AbundanceImpact
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement