Skip to content
Advertisement

Tag: presto

Presto SQL date_format extract week of year

Documentation : https://prestodb.io/docs/current/functions/datetime.html I have epoch timestamps from which I want to extract week of the year like 2021-32, 2020-50, 2021-02 and so on. However I am getting up some wrong values like : week = 2021-53 for Epoch-Time corresponding to Jan 1, 2021 or Jan 2, 2021. I understand that there is a sync issue happening here but that

Count ROW type item Athena / Presto

I have an Athena query like this and the result is I would like to count the number of records per day per devices to have a result like this EDIT My dataset is actually like this Here the expected results would be : Answer You can cast your json to map and count number of keys: Output: device_id date

SQL query to find the second occurrence of an element in a database

For example I have this table: I want to get the row where the PersonID occurs for the second time. So the desired output needs to be (for one of the person ID) : What would be the query for this scenario? Answer Use ROW_NUMBER() Function For this scenario Please Refer this link for how to use this function different

Casting Decimal to Currency in AWS Athena

I have a field value(decimal(23, 2)) and I am querying over it like this: sum(value) and as output i get 1200000.32 I am trying to cast it to currency to get $1.200.000,32 like this: How can I get the desired currency type? Answer There is no money type in presto. And Amazon’s version of presto does not support format and

Presto – Convert Table into Map

I would like to convert the below table into a map with multiple key/value pairs label_a label_b 1 2 3 4 5 6 into {‘label_a’ -> 1, ‘label_b’ -> 2} {‘label_a’ -> 3, ‘label_b’ -> 4} {‘label_a’ -> 5, ‘label_b’ -> 6} What would be the easiest way to do this? All the results I’ve found are scala/non-presto solutions and

Advertisement