I have a strange problem: There is a price in a JSON column in a table and the following statements give different results while they should give the same thing: Just to check I also added a JSON_EXTRACT(item.price_details, “$.shipping.price”) AS shipprice Result: MariaDB version: mariadb Ver 15.1 Distrib 10.3.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 DB Fiddle (I couldn’t use
Tag: coalesce
Group-by and coalesce cannot be combined, gives an error?
I am creating an SSRS report and while making the data queries to it I got into this error. I do need the data set (Month to Date and Year to Date values) in one row connected with a group by command. This is the crystal report I’m referring to and converting to SSRS. The error I get is something
How to concatenate two different values from two different columns with comma ” , ” using TSQL?
I would like to know how to concatenate two different values from two different columns from a SQL table using TSQL ? As you can see, I would like to concatenate those two different columns X e Y, resulting in the follow column table: Which query should be used here ? Answer You can use concat as
SQL ROLLUP with COALESCE
The data: The query: The output I get is like this: It gives null every individual brand item not grouped, and I want the last null to be ‘Grand Total’ not ‘Monthly Total’. I tried putting PurchaseDate or Brand column in and out the ROLLUP but it doesn’t seem to work for the Brand to be grouped. My desired output
In SQL, how do I coalesce the first value of 3 columns that is 10 characters long
I am trying to only select one column from 3 distinct phone number columns, and I would prefer to have the column with the longest phone number (some don’t have area codes). Currently, I have coalesced the 3 columns as some are also null, with a preference on cell phone. Ex. What I’ve tried : I would prefer to just
MSSQL COALESCE function with multiple non null values
I am trying to get data (T_Stamp, Destination, Weight, Line) from two tables using variable time intervals and a destination selection. This is going into an Ignition SCADA. My SQL code below works for most cases except when there are entries into both tables with the same timestamp. In those cases it shows only the data from table A. This
Replace NULL values per partition
I want to fill NULL values in device column for each session_id with an associated non-NULL value. How can I achieve that? Here is the sample data: +————+——-+———+ | session_id | step …
SQL – sum a column with common id, then coalesce total with another column
I know somebody can tell me what I’m doing incorrectly here. This is a postgresql db. I’m trying to first sum the values in a column that share the same ID, and then add that total (coalesce) with …
Using COALESCE correctly in WHERE clause
Can someone explain why coalesce doesn’t work in the where clause given the following conditions below? How do we use coalesce correctly in this case without changing the below coalesce conditions and only for spoiled = Y? Table Fruit: Query: Using the query above will not return anything. Desired output should be grapes. Desired Output: Answer We can use ROW_NUMBER
Can I use a derived column in SQL Server for performing a CASE function?
I have a ‘main’ table, C1, which has a record identifier, which in turn may be linked to either an account or a customer ID. The relationship / linkage is stored on two separate tables, one with record ID – Account level relationship, and the other with record ID – Customer level relationship. It is possible for C1 records to