|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hello,
I was looking for a way to generate a column's value by concatinating the values of 2 other columns in the table (same record). DB2 asks for a "Formula" to do this but I have been thusfar unable to find the syntax of such a formula. A link to what sort of "Formula" they are looking for and possibly the formula's syntax would be greatly appreciated. Thanks for your time. -Brent "I need more practice at getting things right the first time" |
|
#2
|
|||
|
|||
|
try this:
SELECT (column1 + column2) AS newColumn FROM TABLEX or SELECT CASE WHEN column1 > 0 and column2 > 0 THEN column1 + colmn2 ELSE 0 END AS newColumn FROM TABLEX or you can use SUM function |
|
#3
|
||||
|
||||
|
If you are wanting to concat two fields, then you can use the concat fuction, or the || operator. This only works on character style fields though so if you are working with numeric fields you will have to cast them as char() when passing them into the concat function.
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2.doc.sqlref/bjnrmstr215.htm i.e. select concat('a','b') from some_table fetch first 1 row only would return ab or select 'a' || 'b' from some_table fetch first 1 row only would return ab |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > Value Gen Formula |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|