Skip to content
Advertisement

Tag: database

SQL query to filter columns

I have a question regarding the SQL query. I have this table shown below Region Rep Item Quebec Jones Pencil Ontario Kivell Binder Ontario Jardine Pencil Ontario Gill Pen Alberta Sorvino Pencil Quebec Jones Binder Ontario Andrews Pencil Ontario Jardine Pencil Alberta Thompson Pencil Quebec Jones Binder Ontario Morgan Pencil Quebec Howard Binder Alberta Sorvino Pen Alberta Thompson Binder Ontario

How do I parameterize table & column in a Postgres-custom-function, selecting PK if value exists, otherwise insert it and return PK anyways?

Trying to do what I specified in the title, I already got the upsert-functionalities working, however when I try to parameterize it, I’m just out of my depth and can’t debug it. My query: now when I try to use the function, I get: What puzzles me about this is the fact that this syntax works fine in an unparameterized

Make table out of different columns and assign values to add them up

I want this: where a win equals 3 points, a win in PV equals 2 points and a lose in PV equals to 1 point, to show like this: I just can’t figure out how to connect the values with SQL-Statements! Any help is appreciated 🙂 Answer You can do: Alternatively, you can filter out rows first and aggregate at

DB2 SELECT from UPDATE Options

I am currently trying to do an However, the version of DB2 I have does not appear to support this Is there any alternative to this in DB2 that could be return a desired result? Where in one query we can Update and Return the result? EDIT – The Select statement is supposed to return the values that are to

Find value that is not a number or a predefined string

I have to test a column of a sql table for invalid values and for NULL. Valid values are: Any number and the string ‘n.v.’ (with and without the dots and in every possible combination as listed in my sql command) So far, I’ve tried this: The regular expression also matches the single character values ‘n’,’N’,’v’,’V’ (with and without a

Get data from database and write it back in again

I have written a function by reading an excel file and writing it to the database. This works! Getting data from the database also works. Where I get stuck is at the point that the function should read each row, calculate it and write the result back to the database. I also want to find out how many rows were

Advertisement