I can directly unnest an array from a literal in BQ as follows: select * from unnest([1,2,3]) # [{“f0_”: “1”},{“f0_”: “2”},{“f0_”: “3”}] …
MySQL query to select a record from each group that meets a user-defined criterion
I am looking for a query that selects a record from each group that meets a user-defined criterion. I can explain with the following illustrative table: A simple GROUP BY categoryID query returns the first record in each group, as shown below: To return the last record in each group we can use the approach suggested here: However, what I
Output two rows from the same row with special numbering
I have a table Products ID Company Product Weight Price Date — ——- ——- —— —– —- 1 555 blanket 3 10 20201207 2 555 blanket 7 45 20201208 3 555 blanket …
Return all data where a value does not exist
I want to know if a job does not have an ‘LI’ CompCode. SELECT bSLHD.Job, SLCT.SL, APVM.Vendor, APVM.Name, SLCT.CompCode, SLCT.ExpDate FROM bSLHD INNER JOIN SLCT ON bSLHD.SL = SLCT.SL …
Get the Defect Type with the maximum Total Defect Qty
I have the following query which gets the sum of defect quantity per Defect Type : SELECT [Defect Type] ,YEAR([Date]) AS YearOfDefect ,SUM([Total Defect Qty]) AS [Sum] FROM SupplierQuality GROUP BY […
I want to update my table columns based on another one
I have one database that I’ve created a year ago but then I’ve created a new one recently and added some new columns into tables. I want to update my ex database with new schema without losing my data….
Compilation throws `None of the following functions can be called with the arguments supplied`
Trying to implement a custom JSONB binding that maps to an object containing a map. Generated code throws a None of the following functions can be called with the arguments supplied error caused by the following line: Here’s my configuration: Also, it seems like the line causing problems is mapping database data to JOOQ’s default JSONB object. Is that what’s
How to pass a seed value to random order function in Sequelize
In SQL dialects you can sort by random and you can pass a seed to the random function in order to get a repeatable random order of rows. In MySQL you’d do it like this: SELECT * FROM `users` ORDER BY …
SQL: Change the value of a column in function of another
I get a table from SQL that I put whitin a winform’s datagridview. I just want to change the value of my last column in funtion of another. Here is the example: I have 4 columns : ID / Price / …
SQL Query count with group by and having at least one date filled
I need to write a sql query where I count number of employees who are not featured. Each employee can have multiple records with member comments. If they are featured then the feature date will have …