BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: d^_^b►►ทิว ที่ มิถุนายน 25, 2012, 15:38:22 PM
-
ผมใช้คำสั่งประมาณนี้ครับ
select * from pq_doctor
where doctor_date between "2012-06-01" and "2012-06-01" and doctor in ("001")
and doctor_time between "08:00:00" and "16:00:00" order by doctor_time limit 10
แน่นอนว่าจะได้ข้อมูลมา 10 รายการ เรียงจากเวลาน้อยไปหามาก ทีนี้ ผมแทรกคำสั่ง group by doctor_date
เข้าไป มันจะยุบให้เหลือรายการเดียวใช่ไหมครับ ถามว่า
รายการที่เอามาแสดงมันเป็นเวลา doctor_time ช่วงไหน แล้วถ้าผมอยากให้เอาเวลาที่น้อยที่สุดมาแสดง จะทำยังไงครับ
-
select q.*
from (select min(vn) vn
from pq_doctor
where doctor_date between "2012-06-01" and "2012-06-01"
and doctor in ("001")
and doctor_time between "08:00:00" and "16:00:00") a
left join pq_doctor q on a.vn=q.vn