Relative Content

Tag Archive for sqlpresto

How to use CASE with CONTAINS and Array Aggregation

I am trying to write a query using a CASE statement that is based off whether a value is in array, but I run into the catch 22 of not including the case statement in the GROUP BY and getting “must be an aggregate expression or appear in GROUP BY clause” or including it in the GROUP BY and getting “GROUP BY clause cannot contain aggregations, window functions or grouping operations” so I know I’m missing something. My query is:

How to find how many sessions had specific action from JSON column in SQL

I have a table with 2 columns, session_id and json_column. Each row is at session level and json_column has all the event name <> event time stamp a user took during that session. event names are not repeated so it will have one event time stamp for each event name. For example lets assume the table has only 2 rows and json_column value will look like this for those rows,

PreSQL contains semicolons

I executed the following code and found the following issues:
select regexp_replace(e,’;’) as d1