Skip to content

Find top parent of child, multiple levels

I make copies of the entries in some cases and they are conneted by parent ID. Each entry can have one copy: Sometimes I need to take a copy and query for it’s top level parent. I need to find the top parent entries for all the entries I search for. For example, if I query for the parents of

Get best hit first

I have a table department with a columns SearchKeysName and BOLD_ID. Bold_ID is just a number for identification of row. It contains data like this: To search data I have SQL like this: In this case I searched for 32-1 so it will pick the rows above. What I want is to make sure the exact hit is placed on

Summarize unique column in row

I’m new to Firebird and need your help. I have a stored procedure with following reduced output: Player Team Number Reus Ahlen 18 Lewandowski Posen 19 Reus MG 11 Reus BVB 11 Lewandowski BVB 9 Haaland BVB 9 I want to summarize the Players and transform Team&Number to a new column. The output should b…

Not enough values selecting into a table value

Here is the code: and the following function doesn’t compile: It says: PL/SQL: ORA-00947: not enough values Why is that? Answer Why is that? You are trying to put 3 values (and multiple rows) into a single variable. Use BULK COLLECT INTO and wrap the values in the object type: Given the sample data: The…

simplifying postgres queries

Note: Asking to improve the working code. My data column is as follows In the above data, I want to set available to false and price to zero. To do this I Am using the below code. My question is it possible to update both values in a single query? Thanks. Answer Sure:

How to get the average of a column in MySQL

I’m trying to find a way to calculate the average of a column (as a double/float or decimal). I’ve found the AVG function in MySQL documentation but I can’t get it to work. Currently I’ve got the following code: Now for some reason this does not work. It returns “Unable to cast o…

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 charact…