Skip to content
Advertisement

Tag: db2

DB2 Iseries 4 Issue casting date from decimal

I have decimal fields (DECIMAL(8,0)) that contain dates as 5122019 for may 12th 2019 and 12122020 as December 12th 2020. I’ve tried several ways to convert including DATE(TIMESTAMP_FORMAT(CHAR(decimalField),’MMDDYYYY’)) but they return null. What’s the best way to do this with a decimal 8,0 field when the single digit months don’t contain a leading zero? Answer It works if you use

Efficient way to ignore whitespace in DB2?

I am running queries in a large IBM DB2 database table (let’s call it T) and have found that the cells for column Identifier tend to be padded not just on the margins, but in between as well, as in: ‘ ID1 ID2 ‘. I do not have rights to update this DB, nor would I, given a number of

SQL subquery with aggregate value

Sorry for the vague title, I’m a little lost here. I have two simple aggregate SQL queries, but I struggle to combine them in a functional way (likely through a subquery) in IBM DB2. Main goal is to run COUNT function in INVOICES table – but with the starting date based on a subquery MAX aggregate result. But as noted,

Advertisement