Skip to content

Tag: sql

SQL average of a subset of a column

Give the table “shop” Is there a way to find the list of products(whether A or B) whose price is less or equal to the average price or type A? I tried the following: Answer Use a subquery to find the average price of type A items: Just for fun, we could also use analytic functions here: Demo

Mysql if Null or Empty String then Show N/A

Hello I’m new to mysqsl and I’m trying to display N/A if the return data is empty or NULL but my query is unrecognized statement type. What do you think is wrong with my query? wrong placement of code? END Answer Use IF with ISNULL here: If you really wanted to use a CASE expression, then it would…

Oracle move strings to another matching row

I have a table called tblrespondent and my data looks like this: I have several case numbers that have multiple rows like this and I need to move all the comments into the lowest orclid13. The result would look like this with a semicolon in between each comment. How would I approach this? Many thanks in advan…

Json extract coming as null – Presto SQL

I`m trying to use json extract to get some values using the code below: And it works, however the values are coming all as NULL . When I extract the properties field I get the values that I want, as the example below: {“allow_url”:false,”partner_target_app_id”:[28479748204829001,938801…