Tagged Questions
6
votes
6answers
395 views
Find “n” consecutive free numbers from table
I have some table with numbers like this (status is either FREE or ASSIGNED)
id_set number status
-----------------------
1 000001 ASSIGNED
1 000002 FREE
1 000003 ...
4
votes
2answers
115 views
Select longest continuous sequence
I am trying to construct a query in PostgreSQL 9.0 that gets the longest sequence of continuous rows for a specifc field.
Consider the following table:
lap_id (Serial), lap_no (int), car_type ...
2
votes
1answer
247 views
Find which numbers in [1, 161] are not in the result set?
How to find which two number in [1, 161] is not in the result set?
Can I find this two numbers using sql command?
mysql> select blog_id from wp_blogs;
...
| 149 |
| 150 |
| 151 |
| ...
1
vote
3answers
257 views
Find and remove gaps in sequence across two different columns
I've tried to solve this problem using a set-based approach. However, since I need to look at each row I think I must use a cursor; please correct me if I'm wrong.
The table:
Project, item, method, ...
4
votes
2answers
577 views
Updating rows conditionally with a gapless ascending value
A user has a table they would like to update. Depending on the data in other columns they want a particular column to be updated with an ascending value starting from 1 that is gap-less. The rows ...