Convert Varchar to Int and SUM

  • SELECT SUM(TRY_CAST(LEFT(RE80_VALORE, CHARINDEX('.', RE80_VALORE + '.')) AS int))
    FROM dbo.RE80_MOVSCHPUNTI INNER JOIN
    dbo.RE14_DOCTESTATA ON dbo.RE80_MOVSCHPUNTI.RE80_IDDOCTESTATA_RE14 = dbo.RE14_DOCTESTATA.RE14_ID
    WHERE (dbo.RE80_MOVSCHPUNTI.RE80_INDTIPOMOVSCH = 1) AND (dbo.RE80_MOVSCHPUNTI.RE80_DATAMOV = CONVERT(DATETIME, 'DATA RANGE', 102)) AND
    (dbo.RE14_DOCTESTATA.RE14_IDNEGOZIO_RE05 = 1)

    From what you have given, if you only need the SUM of RE80_VALORE then you just replace your select with what Scott already provided.

     

    Again what you have posted above isn't enough to work out what you need.  To enabled us to re-create the problem to help you please do again go back and read that link, we need CREATE TABLE statements, INSERT INTO statements to create your tables and data.  What you have tried so far.  And what you expect the outcome to look like.

     

    Without any of what that link details, we are just clutching at straws guessing what it is you actually need

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply