Skip to content

Use another column as default value in migration

I am trying to add a new column to existing tableName table which has a column anotherColumn. exports.up = function (knex, Promise) { return knex.schema.table(‘tableName’, table => { …

CASE expression in WHERE clause for diferent and

Can I use case expression to build where like this? I need change where clause depending on the value of x variable. Answer An alternative to using OR is to use nested CASE statements: or you could simplify it to: However, you should check whether Oracle can use column indexes or if a separate function-based …

Transform table to smoothen records in one column

the situation (a real life situation) is: I have a table with “log” records, for simplicity let’s assume there are only columns NAME, TIME, STATE (in reality there are few more). There are cca 1 Milion rows in which there are 100 Names (computers) and cca 10 states (productive, idle, automat…

SQL Extract Values from Timestamp Difference

I’m trying to extract Days, Hours, Minutes, Seconds from the output of subtracting two timestamps in an Oracle database. I then want to take the extracted values and put them into separate columns. I …