Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
andryi
Starting Member
17 Posts |
Posted - 2010-02-24 : 11:39:05
|
| hi everybody, I've got a problemSELECTsubstring(A.tanque1,charindex(':',A.tanque1)+1,charindex(')',A.tanque1)-charindex(':',A.tanque1)-1) AS CAPACTIDAD1,substring(A.tanque2,charindex(':',A.tanque2)+1,charindex(')',A.tanque2)-charindex(':',A.tanque2)-1) AS CAPACTIDAD2,(cast(CAPACIDAD1 as FLOAT) + cast(CAPACIDAD2 as FLOAT)) AS TOTAL123from tableand, I want to sum capacidad1 plus capacidad2 so I cast the column to foalt, but nothing work, only have null how result |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-24 : 11:42:03
|
may be thisSELECT CAPACTIDAD1,CAPACTIDAD2,(COALESCE(cast(CAPACIDAD1 as FLOAT),0) + COALESCE(cast(CAPACIDAD2 as FLOAT),0)) AS TOTAL123FROM(SELECTsubstring(A.tanque1,charindex(':',A.tanque1)+1,charindex(')',A.tanque1)-charindex(':',A.tanque1)-1) AS CAPACTIDAD1,substring(A.tanque2,charindex(':',A.tanque2)+1,charindex(')',A.tanque2)-charindex(':',A.tanque2)-1) AS CAPACTIDAD2from table)t------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
andryi
Starting Member
17 Posts |
Posted - 2010-02-24 : 12:02:52
|
| thank's for your reply visakh16, It WORKS :D, thank you very much |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-24 : 12:05:35
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
donald1
Starting Member
4 Posts |
Posted - 2010-02-24 : 15:59:56
|
quote: Originally posted by visakh16 may be thisSELECT CAPACTIDAD1,CAPACTIDAD2,(COALESCE(cast(CAPACIDAD1 as FLOAT),0) + COALESCE(cast(CAPACIDAD2 as FLOAT),0)) AS TOTAL123FROM(SELECTsubstring(A.tanque1,charindex(':',A.tanque1)+1,charindex(')',A.tanque1)-charindex(':',A.tanque1)-1) AS CAPACTIDAD1,substring(A.tanque2,charindex(':',A.tanque2)+1,charindex(')',A.tanque2)-charindex(':',A.tanque2)-1) AS CAPACTIDAD2from table)t------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
i agree with u go ahead with him......correct.(link removed) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-25 : 09:37:17
|
quote: Originally posted by donald1
quote: Originally posted by visakh16 may be thisSELECT CAPACTIDAD1,CAPACTIDAD2,(COALESCE(cast(CAPACIDAD1 as FLOAT),0) + COALESCE(cast(CAPACIDAD2 as FLOAT),0)) AS TOTAL123FROM(SELECTsubstring(A.tanque1,charindex(':',A.tanque1)+1,charindex(')',A.tanque1)-charindex(':',A.tanque1)-1) AS CAPACTIDAD1,substring(A.tanque2,charindex(':',A.tanque2)+1,charindex(')',A.tanque2)-charindex(':',A.tanque2)-1) AS CAPACTIDAD2from table)t------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
i agree with u go ahead with him......correct.
Are you his manager? ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
donald1
Starting Member
4 Posts |
Posted - 2010-02-25 : 15:59:32
|
quote: Originally posted by visakh16
quote: Originally posted by donald1
quote: Originally posted by visakh16 may be thisSELECT CAPACTIDAD1,CAPACTIDAD2,(COALESCE(cast(CAPACIDAD1 as FLOAT),0) + COALESCE(cast(CAPACIDAD2 as FLOAT),0)) AS TOTAL123FROM(SELECTsubstring(A.tanque1,charindex(':',A.tanque1)+1,charindex(')',A.tanque1)-charindex(':',A.tanque1)-1) AS CAPACTIDAD1,substring(A.tanque2,charindex(':',A.tanque2)+1,charindex(')',A.tanque2)-charindex(':',A.tanque2)-1) AS CAPACTIDAD2from table)toh...how do u know...very good------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
i agree with u go ahead with him......correct.
Are you his manager? ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
oh really..???...how do u know me.(link removed) |
 |
|
|
|
|
|
|
|