By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

Finding sequences in a query‏

P: 1
I'm am making a small programm for seat reservations. But I have a problem to find the sequence in the available seats. I will explain it with the following sample:
Expand|Select|Wrap|Line Numbers
  1. Row / Seat / Total Seats In Sequence / Sequence number / Available
  2. 1   /  1   /              3          /        1        /     3
  3. 1   /  2   /              3          /        2        /     2
  4. 1   /  3   /              3          /        3        /     1
  5. 1   /  6   /              4          /        1        /     4
  6. 1   /  7   /              4          /        2        /     3
  7. 1   /  8   /              4          /        3        /     2
  8. 1   /  9   /              4          /        4        /     1
  9. 2   /  1   /              3          /        1        /     3
  10. 2   /  2   /              3          /        2        /     2
  11. 2   /  3   /              3          /        3        /     1
  12. 2   /  8   /              2          /        1        /     2
  13. 2   /  9   /              2          /        2        /     1
If have tried to do it with Dcount but this function is very slow. The output of available seats is the row that I use for the rest of the database.

Please let me know if you have a better solution to get the availeble seats next to each other as an output.

For example if I need 3 seats the system have to give me to following options:
Expand|Select|Wrap|Line Numbers
  1. Row / Seat / Total Seats In Sequence / Sequence number / Available
  2. 1   /  1   /           3             /        1        /     3
  3. 1   /  6   /           4             /        1        /     4
  4. 1   /  7   /           4             /        2        /     3
  5. 2   /  1   /           3             /        1        /     3
Hope that you can help me, maybe Ecount works better but I can't figure out I can make it work for my query.

Best regards
Bart
Feb 11 '09 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello, Bart.

Frankly speaking I don't understand the meaning of 3 last fields.
However, to determine contiguous seat groups you need only Row, Seat, Reserved/Available fields. The rest is redundant.

Is that the case or the fields have some special meaning?

Regards,
Fish.
Feb 11 '09 #2

ADezii
Expert 5K+
P: 8,623
I do agree with FishVal concerning the redundancy, but in any event, here is the SQL. Better yet, download the Attachment.
Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Enter Minimum Number of Seats Needed] Long;
  2. SELECT tblSeatReservations.Row, tblSeatReservations.Seat, tblSeatReservations.[Total Seats in Sequence], tblSeatReservations.[Sequence Number], tblSeatReservations.Available
  3. FROM tblSeatReservations
  4. WHERE (((tblSeatReservations.Available)>=[Enter Minimum Number of Seats Needed]));
Feb 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.