I use access db, i use this query :
, i got new problem !Code:"select top 1 no_booking from booking where date_service in (select top 1 date_service from booking group by date_service having count (date_service) < 4) order by no_booking desc"
when the condition data on table booking like this :
+------------+--------------+
| no_booking | date_service |
+------------+--------------+
| AN02091701 | 02/09/2017 |
| AN02091702 | 02/09/2017 |
| AN02091703 | 02/09/2017 |
| AN02091704 | 02/09/2017 |
| AN03091701 | 03/09/2017 |
| AN03091702 | 03/09/2017 |
| AN03091703 | 03/09/2017 |
| AN03091704 | 03/09/2017 | --> date_service 04/09/2017 (is doesn't have no_booking)
| AN05091701 | 05/09/2017 |
| AN05091702 | 05/09/2017 |
| AN05091703 | 05/09/2017 |
| AN07091701 | 07/09/2017 |
+------------+--------------+
i know my query just select to AN05091703 on date 05/09/2017,and the next command i make next no_booking AN05091704 .
but i want too select or find date 04/09/2017,and then make new no_booking AN04091701 .
assumtion we don't know un-available date..
how to make correct query ?




Reply With Quote
