Skip to content
Advertisement

Tag: trino

Grab Latest Data Based on String

I have a table with Forecast, Budget, & Actuals. I need to grab the latest data based on the month which is prefixed in the d_period field (Ex: Jan, Feb, Mar, Apr, etc.). The query should always default to the latest month (no relation to current month – the upload varies so it could be 2 months ago, 4 months

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

count and sum in case statement

What is the difference below if I use case instead of sum? I believe I would get the same output? Thanks! Answer The three are equivalent. All of them count the number of rows that meet the particular condition (salary > 100000). All return 0/1 and would not return NULL values for the column. From a performance perspective, all should

WHERE followed by ON clause

What is the semantic difference between the following queries? To me both seemed similar until I executed them on presto. Is this something specific to presto or am I missing something in the SQL standard? Form 1: All conditions specified in the ON clause. Form 2: Some conditions specified in the WHERE clause instead. Form 1 results in some rows

presto sql filter part of the string java

I have a string in col1 select col1 from table “blah blah 123 blah iterate 866 loss blah blah” how to filter string between iterate and loss and just show sum of all such filtered numbers ? Answer You can use regexp_extract to extract the number within that string, convert the values to a numeric type and sum them up:

Advertisement