Can this be done in one query?
This is my DB structure:
ID PRICE DATE CODE
1 23 2011-02-01 23:23:23 AAA
2 23 2011-02-04 22:01:01 BBB
3 25 2011-02-05 00:00:01 AAA
4 21 2011-01-09 00:00:00 BBB
5 20 2011-02-09 00:00:00 BBB
I'm trying to construct an SQL query that will produce the rows that PRICE is over 22 in ALL dates that are greater than 2011-01-30 23:59:59
So if we take the above structure as an example, it will produce one row that gives the CODE AAA as the price was above 22 in both dates that are greater than 2011-01-30 23:59:59. BBB should not match, because even though it has a price above 22 after the cut-off date, it also has a price after the cut-off date that isn't above 22.