Skip to content

Quartiles in Postgres

I have payment amounts like so – How do I divide records like this into quartiles. It doesn’t have to be perfect. For example, the data in the question would transform like so – Ids 124049 and 2323 are given the same quartile because those payment values are close together. Answer you can us…

Show when order number is unique for the item number

I attached a simple table with two columns, Item number and Order number. In the example attached only item number C5664 and A9930 met the criteria. How do I write this code in SQL? Answer If you group by the item numbers then the unique count for the order numbers will be 1

Oracle procedure saving SYSDATE

As part of a larger procedure I’m trying to write some code, which saves SYSDATE into a variable but I’m running into a problem. I narrowed it down to the following. Can someone please help me out. Answer In PLSQL you can just assign: if you insist on sql all you have to do is to add into after se…

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