Skip to content

Calculate the rank and apply it following an order

I want to calculate the dense rank over a group by clause and set my rank in order of my line id i.e the smallest ids get the first rank and so on. I am able to retrieve the dense rank of my lines …

Reverse group by and counts

I have tables for questions and answers. Each question can have 0 or multiple answers. When you left join the tables you get something like this: q1 a1 q1 a2 q2 a3 q3 NULL q4 NULL q5 a4 …

SQL getting balance point of two cumulative sums

Bellow I provide a code, which does the job on this interesting task to some extent, but may be poorly designed due to my SQL knowledge limits. The main problem is, that the query gives random (more …

SQL to concatenate all Query rows into one row

I have seen the following questions but can’t get them to work for what I’m looking for. How can multiple rows be concatenated into one in Oracle without creating a stored procedure? SQL Query to …

How to get row number for each null value?

I need to get row number for each record of null by sequence. Restart number when get a value in the row. I have tried so far select * , ROW_NUMBER() over (order by id) rn from @tbl select * …