I want to use REGEXP_REPLACE sql function (I’m targeting Postgres), but after quick inspection of DSL class in JOOQ it seems that it is not exposed yet. How should I approach the problem of adding …
Sort a table but keep groups of rows together
How do I sort a table by it’s minimum value per group but at the same time keep a group of rows together. Below a simple example of what i am trying to accomplish. The table is sorted by the lowest group value, but the group remains together. I am pretty sure this question has been asked already but i
UNION based on common column
I have 2 tables: And I want to create UNION query, based on the common rows of EAN. Like, in the end, I want my table to look like: Any helps would be really appreciated! Thanks in advance!
Find rows with column equal and other different
I need to extract all rows that have same column value (wihout duplicates) and the other column value with different value. I have problems when I’m trying to get null values since the sentence “…
How to use scalar variable in XML Path query SQL?
I want to pass table name into into a scalar variable @Table_Name as a string. But I am getting error as: Must declare the table variable @Table_Name. How to achieve the same? Below is my code snippet: Answer So I created a temporary table using the input provided by the user and used that temp table in the query. Following
Group by not getting the expected results in mysql
I have the next query: That is working perfectly and returning 9 rows: I want to group the results by boat type and get the number of boats per type. However, when I do: I´m getting: but according to the first query, I´m expecting What am I missing? Answer I suspect that you want: That is: move the DISTINCT within
SQL – Get the antepenultimate (before previous group/phase)
I have the following table and I’d like to get the antepenultimate or the value before the previous value. I already have group, value and prev_value, dateint… I’m trying to derive prev_prev_value This is the table with test data (as a CTE) Any ideas on how to derive prev_prev_value I’d like to use window functions and avoid joins. I’ve tried
How to return only one row per course
I am trying to return a list of course IDs that contain three components: assignments, discussions, and a syllabus. I want my results to have only one row per course ID with either Y’s or N’s …
using condition for Group_Concat
I want to find all ids of which group_concat only contains ‘a’. Here is simplified table from mine. ╔════╦══════════════╦ ║ id ║ group_concat ║ ╠════╬══════════════╬ ║ 1 ║ a,b,b ║ ║ 2 ║ a …
MySQL – Select on varchar column with 0 (zero) as criteria returns all rows?
Sorry in advance – this seems like a really dumb question. But… If I run a select query on a varchar() column, but use zero for the column value in the where clause – why does it return all rows? …