MS SQL Server 2008 Schema Setup:
create table YourTable
(
ID int,
COL1 int,
COL2 int
)
insert into YourTable values
(1 ,7 ,2),
(2 ,7 ,3),
(3 ,7 ,4),
(4 ,7 ,5),
(5 ,9 ,2),
(6 ,9 ,3),
(7 ,9 ,4),
(8 ,9 ,5),
(9 ,11 ,2),
(10 ,11 ,3),
(11 ,11 ,4),
(12 ,11 ,5)
Query 1:
select *
from YourTable
where (COL1 > 7 and COL1 < 11) or
(COL1 = 7 and COL2 >= 3) or
(COL1 = 11 and COL2 <= 2)
| ID | COL1 | COL2 |
--------------------
| 2 | 7 | 3 |
| 3 | 7 | 4 |
| 4 | 7 | 5 |
| 5 | 9 | 2 |
| 6 | 9 | 3 |
| 7 | 9 | 4 |
| 8 | 9 | 5 |
| 9 | 11 | 2 |