Skip to content
Advertisement

Tag: presto

Extracting timestamp from timestamp with time zone Presto

Is there a native Presto function that provides support to extract the timestamp from a timestamp with time zone? Taking something like this Which returns a value of: 2022-03-13+02:00:99 UTC To: 2022-03-13+02:00:99 I couldn’t find information in the docs for this kind of support. It seems as though my only option is to convert this as a varchar, remove the

How to unpack array as columns

I have a table that looks like this: date volume_info 2022-01-01 {“temple”: 18348, “benny”: 8524, “polly”: 1698, “sally”: 5860} 2022-01-02 {“temple”: 2000, “benny”: 1000, “polly”: 3904, “sally”: 1776, “benjamin”: 2} And I am trying to set it up like this: date temple benny polly sally benjamin 2022-01-01 18348 8524 1698 5860 NULL 2022-01-02 2000 1000 3904 1776 2 But I

Count all records and output values once a condition is met [SQL]

I would like to count all customers and return the signup date for the 3rd customer who has signed up. Essentially evaluate the number of customers that signed up and once the count of customers that have signed up reaches 3 to return the signup date and the id of the 3rd customer sample table output table Answer Use row_number()

Presto lag dates, group/partitioned by id

Say that I want to find every time that a client updated their budget. Here’s what my data looks like And the code I’ve run. What I’m expecting returned will be Hence there are NULL values for dt_2 in the first entry of each client_id. I’m not sure what code will accomplish this effect; is a GROUP BY clause will

Adding hours to dates in Presto

In a Presto db table, I have two string fields, a date of the form, ‘2022-01-01’, and an hour of the form, 22, for 22:00. I’m trying to combine these two elements into a proper timestamp, with date, hours, minutes, seconds. How can I accomplish this? What I’ve tried so far However, I get the error that ‘hour’ is not

Results of an UNION in two columns

I am querying names from two tables: And I get the result I want in a single column. Now I want to know if it is possbile to get the results in two different columns like: “names_from_data1”, “names_from_data2” Or another way to identify where each name comes from: data_1 or data_2 Answer You can add hardcoded column to indicate the

Advertisement