BMS-HOSxP Community
HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: Guitar-hero ที่ กุมภาพันธ์ 10, 2010, 20:55:04 PM
-
คือผมต้องการปรับปรุงข้อมูลบางอย่างในตาราง ovst โดยปรับปรุงเฉพาะเดือนครับ คำสั่งที่ผมใช้เป็นดังนี้
update ovst set spclty='01'
where main_dep='13' and vstdate between '2009-06-01' and '2009-06-01'
แต่มันดึึงมาทั้งหมดครับ มันไม่เลือกมาเฉพาะเดือนที่เลือก ไม่ทราบว่าผมเขียนคำสั่งผิดตรงไหน มือใหม่ครับ ช่วยแนะนำหน่อยครับ
-
ลองทดสอบแล้ว ข้อมูลก็มาเฉพาะวันที่กำหนดเองนะครับ
-
ก็น่าจะถูกต้องแล้วนะครับ
-
น่าจะแก้ข้อมูลใน vn_stat ด้วยนะครับ
เพราะหลาย ๆ รายงานมักจะดึงข้อมูลจากตารางนี้ เพื่อลดความซ้ำซ้อนของคำสั่งในการดึงข้อมูล
-
น่าจะได้แล้วนะครับ ของผมใช้แบบนี้
update ovst set spclty = '01' where main_dep = "052" and vstdate = "2009-04-09"
แต่ว่าช้าครับ กำลังจะทำแบบว่า ให้ update spclty ทั้งหมดที่ว่างอยู่ โดยให้ไปอิงกับ ตาราง kskdepartment เพราะว่ามี spclty ที่เป็นค่าว่า่งมากเหมือนกันครับ
ลองอยู่ 2 คำสั่งแต่ยังไม่ได้เลยครับ ;D
;Dupdate ovst set spclty =
(select spclty from kskdepartment where kskdepartment.dep = ovst.cur_dep)
where cur_dep in (select cur_dep from ovst where ovst.cur_dep = kskdepartment.dep and
ovst.spclty < "0" and ovst.vstdate = "2009-04-09")
update ovst set spclty = (select kskdepartment.spclty from kskdepartment,ovst
where kskdepartment.depcode=ovst.cur_dep)
where spclty < "0" and vstdate = "2009-04-09"
-
วันนี้ก็ยังไม่ได้เหมือนกัน ;D
ขอดันครับ เผื่อ อ.ท่านใดทำได้แล้วครับะ ;D
-
ท่านใดลองแล้วได้ผล รบกวนด้วยครับ ???
เพราะฟิลด์คลินิก ของผมว่างเยอะครับ(เกิดจากตอนนัด แล้วไม่ได้ใส่คลินิก เมื่อส่ง visit ล่วงหน้าก็เลยไม่มี คลินิกออกมาน่ะครับ) เดี๋ยวส่งข้อมูลแล้วมีปัญหาน่ะครับ ;D ;D ;D
-
ตอนนี้ก็ทำแบบนี้ไปก่อนครับ ;D
update ovst set spclty = "01" where (main_dep = "002" or main_dep = "003" or main_dep ="007" or main_dep = "009" or main_dep = "010" or main_dep = "012" or main_dep = "013" or main_dep = "014" or main_dep = "015" or main_dep = "016" or main_dep = "017" or main_dep = "019" or main_dep = "020" or main_dep = "021" or main_dep = "025" or main_dep = "027" or main_dep = "029" or main_dep = "030" or main_dep = "033" or main_dep = "039" or main_dep = "040" or main_dep = "043" or main_dep = "044" or main_dep = "049" or main_dep = "050" or main_dep = "061" or main_dep = "064" or main_dep = "065" or main_dep = "070" or main_dep = "071" or main_dep = "072" or main_dep = "073" or main_dep = "074" or main_dep = "076" or main_dep = "079" or main_dep = "084" or main_dep = "111" or main_dep = "112" or main_dep = "113" or main_dep = "124") and spclty < "0" and (vstdate between "2009-10-01" and "2009-10-31")
ประมาณนี้ อ่ะครับ ข้อมูลจะได้สมบูรณ์ ;D ;D ;D