Skip to main content
added 84 characters in body; edited title
Source Link
Vérace
  • 31k
  • 9
  • 73
  • 86

detect Detect multiple valid date periods for same id, interleaved with non-valid periods

AnMy table structure and some sample data (test table), as well as my desired output (results) are available example + expected resultshere of my request.

When I do

SELECT distinct colony, min(date_check), max(date_check) from test where protection ='Y' group by colony 

I only detect 1 event by colony.

Should I use a function or is there another way ?

ps : if you think of a better title to help users, don't hestitate, I struggled.

detect multiple date periods for same id

An example + expected results of my request.

When I do

SELECT distinct colony, min(date_check), max(date_check) from test where protection ='Y' group by colony 

I only detect 1 event by colony.

Should I use a function or is there another way ?

ps : if you think of a better title to help users, don't hestitate, I struggled.

Detect multiple valid date periods for same id, interleaved with non-valid periods

My table structure and some sample data (test table), as well as my desired output (results) are available here.

When I do

SELECT distinct colony, min(date_check), max(date_check) from test where protection ='Y' group by colony 

I only detect 1 event by colony.

Should I use a function or is there another way ?

ps : if you think of a better title to help users, don't hestitate, I struggled.

edited tags
Link
user1822
user1822
Source Link
fkt
  • 17
  • 5

detect multiple date periods for same id

An example + expected results of my request.

When I do

SELECT distinct colony, min(date_check), max(date_check) from test where protection ='Y' group by colony 

I only detect 1 event by colony.

Should I use a function or is there another way ?

ps : if you think of a better title to help users, don't hestitate, I struggled.