Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Sum Numbers Within String

$
0
0

select COM, co.KEY, ID, DSCD, SECS,EXCNT

from company cojoinsecurity se on co.KEY=se.KEY 

where co.KEY=285313

 

There are strings in DSCD, and some numbers too. I want to sum in the number within the string in an adjacent field. So, if DSCD contains this:

UNITS (55 CM & 50 PD)

I want to sum the numbers and get 105 in an adjacent field.

 

I thought I could dosum(cast(DSCDasint))As Numbers, then do a GROUP BY, but there are some fields, a lot actually, with no numbers whatsoever.

 

 



Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>