Skip to content

Tag: db2

Retrieve last record in a group based on string – DB2

I have a table with transactional data in a DB2 database that I want to retrieve the last record, per location and product. The date is unfortunately stored as a YYYYMMDD string. There is not a transaction id or similar field I can key in on. There is no primary key. DATE LOCATION PRODUCT QTY 20210105 A P1 4 …

How perform a transaction in ibm db2

I’m working with an accounts table I tried to run this sql which transfer funds from one account to another. I got this error savepoint “FIRST_SAVEPOINT” does not exist or is invalid in this context.. SQLCODE=8080, SQLSTATE=3B001, DRIVER=3.69.56 What could i do ? I’m using IBM Data Stu…

Replace values for each ID and each month in IBM DB2 SQL?

I have about several milion record table in IBM DB2 with 4 columns: yeas, month, personal_number (2 milion), personal_id. The key is that I want to get same table from this one, but I want to fill in personal_id column value from last month (in all previous months). Point is to get 1-1: 1 personal_id relate t…

How to create generated columns in DB2/400

I wanna create a virtual column which concatenates two columns to 1. My attempt was: This should work according to the docs. ( https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzpdf.pdf?view=kc ) (page 851). Has anyone an idea how to get this done? Thanks in advance. edit: I doublechecked it. T…