0

I made this query:

SELECT * FROM appointment WHERE day BETWEEN 1 AND 25 ORDER BY hour

It's return me all appointments of all days, is not bad but I need only 1 result per day.

So, I don't need "count(*) day 1, day 2, day 3..." because I need all information from this appointment.

If day 1 have 5 results, I need only one (and any) result of this day.
If day 2 have 1 result, ok, give me this one.
If day 3 have nothing, ok too
...
If day 25 have 9 results, I need only one (any) result.

Bruno Affonso
  • 101
  • 1
  • 3
  • What is the meaning of the `day` column? – Dai Jul 04 '17 at 01:05
  • 1
    Why aren't you storing date and time values with a single `datetime` value? Are you really storing each component (year, month, day, hour, minute) in separate columns? – Dai Jul 04 '17 at 01:05
  • See the duplicate question, and use one of those techniques to select the first or last row in each `GROUP BY day`. – Barmar Jul 04 '17 at 01:18

0 Answers0