Skip to content
Advertisement

Tag: amazon-redshift

Want to run a query multiple times using a for loop and add each result into a dictionary. This code only execute once even as it loops through

I have a query that take a random sample of records. I want to do this multiple times and add each result into a dictionary, which I will concat into a pandas DataFrame later. This code only execute once even as it loops through. Answer cursor.fetchall() doesn’t execute the query, it just fetches the remaining results from the query that

Redshift : Coalesce Can’t Work As Expected

We’re complementing null value to all zero value like ’00’ on Redshift. Sometimes, I found coalesce function can’t work as we expected. If we use case and len, it can work fine as follows; So far, I have no idea why coalesce can’t work. Any advice would be appreciated. Thank you. Answer There is a difference between ” and NULL

Redshift SQL — transposing rows by id into columns

I am using Redshift SQL. I would like to transpose the distinct rows of “Id1” in “Table” into columns. Thus the output should be like the bottom most table, providing weights as columns for each “Id2”.Or Alternatively, concatenate weights into one column. Any guidance on functions or methods to use will be greatly appreciated. Table Id1 Id2 Weight 1 1

Redshift Postgres 8

I’m trying to write a query to solve a logical problem using Redshift Postgres 8. Input column is a bunch of Order IDs and Step Group IDs and desired output is basically a sequence of the IDs as you can see in the screenshot. If you could help me answer this question, that would be great, thanks! This is a

Advertisement