I have written a function in DB2 – that is calculating ASCII of records in a particular column. I want to some help as I want to check the ASCII of every single character in string return yes if the …
Tag: db2
Does PLSQL in DB2 support nested while statemnts?
I have a following query for DB2 database: BEGIN DECLARE NUMBER_OF_ROWS INT; DECLARE ITER_INDX_1 INT; DECLARE ITER_INDX_2 INT; SET ITER_INDX_1 = 0; SET …
Getting Exception With DB2 Auto Increment
I have created the following table: “CREATE TABLE ParsonCollection ” + “(id integer not null GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),” + “name …
MAX Date for each row
I am having some difficulty at writing a syntax that will provide me with the most recent date for several results. Little bit of background, I am pulling live data from an IBM AS400, I have no SQL tables, I am connecting to the tables via ODBC, using QTODBC to create my queries, then I export them to Power Bi.
How to retrieve the last record in each group with DB2?
As for MySQL, I know how to retrive the last record in each group, such as: But DB2 is a little bit different, you can only select column which is used after GROUP BY, like this: So, if I want to fetch two columns, I need to GROUP BY them like this: here comes the problem, I can’t retrieve the
DB2 query with multiple WITH AS cases not compiling
For some reason, I can’t get this query to perform as I’m getting an error: Token ( was not valid. Valid tokens: , FROM INTO. I’m running this in DB2 and I think this is occurring at either the very …
Create database user with DDL in DB2
I am trying to create a user using DDL in DB2. I tried this: CREATE USER ‘test_user’ IDENTIFIED BY ‘password’; and I got this error message: An unexpected token “‘test_user’ IDENTIFIED BY ‘…
Compare values from one table with average calculation of value with same properties in other table
First post here… I’m trying to create select values from tableA in last 5 minutes and to compare those values each row by row with average(value) from another table. For example: tableA id | …
DB2 – Using Running totals to calculate Month To Date Sales
I’m calculating the Month to date sales using DB2 code to compare July 2019 vs July 2018 totals. It needs to be rolling to compare the current month of data to the same month last year, otherwise I …
SQL: How to determine the most frequent data length in the DB column?
Need to analyze values’ length in DB column and get the % of the Number of the values with the same length. Desire result: Same length values in COL1 = 70% with LENGTH = 10 chars It’s …