I have a schema built in this SQL Fiddle if you want to try it.
I have the following data
AutoID Apartment Flag Description
====== ========= ==== ===========
1 1 NO Device 1
2 1 NO Device 2
3 1 NO Device 3
4 2 NO Device 4
5 2 NO Device 5
6 3 NO Device 6
7 3 NO Device 7
8 3 YES Device 8
9 3 NO Device 9
I am trying to get data with the following rule
- Select only a single apartment price
- IF Flag - YES, then select this item for a single value
So, if I run the SQL statement, I would end up with
AutoID Apartment Flag Description
====== ========= ==== ===========
1 1 NO Device 1
4 2 NO Device 4
8 3 YES Device 8
I am trying to play with OVER () and PARTITION BY with little luck. Any help or guidance is appreciated.
Fylix source
share