Skip to content

Get minimum unused value in MySQL column

I have a table with integer ID column. I would like to get the minimum unused value for this column. The query should find the first hole in table IDs and get the minimum value inside it. I’ll try to explain it with some examples. Example 1: no-holes table In this case, I have a table without holes and …

Calculate Median with SQL (DB2)

I’m having issues calculating the median for my result set and could use some help. I need to provide the median, max, min, avg, and standard deviation. There are 222 rows which can be more or less and I’m not sure what I have so far is an accurate way of calculating the median. Here is my query. …

PostgreSQL:How get last rows from a select query

See the below example, And if I Execute Will Get So,How Can I Get the Last 2 Rows in select * from data? What I’m expecting is…. Answer You have two options according to your need i.e, Or LIMIT and OFFSET if you want the 4th and 5th row just offset the first 3 so that the 4th row becomes