1
我有以下的Mysql查詢,它除了Sum部分之外工作得很好。我得到的結果是,Sum_IO和Sum_NIO被計算在整個表彷彿標準的一部分where子句中的Mysql標準沒有正確報告
Cast(oee_main_interim.TS As date) = CurDate()
被忽略。我要的是查詢只會總結(CURDATE()),它歸入今天的日期值:
Select
oee_main_interim.NAME As Machine_ID,
oee_machinenames.Name As Name,
voee_mach_shifts.curr_Shift As curr_Shift,
Sum((oee_main_interim.Left_IO + oee_main_interim.Right_IO)) As Sum_IO,
Sum((oee_main_interim.Left_NIO + oee_main_interim.Right_NIO)) As Sum_NIO
From
(oee_main_interim Join
voee_mach_shifts On voee_mach_shifts.ID = oee_main_interim.NAME) Join
oee_machinenames On oee_machinenames.ID = oee_main_interim.NAME
Where
Cast(oee_main_interim.TS As date) = CurDate() And
oee_main_interim.Shift In (Select
voee_mach_shifts.curr_Shift
From
voee_mach_shifts Join
oee_machinenames On oee_machinenames.ID = voee_mach_shifts.ID
Group By
voee_mach_shifts.curr_Shift, oee_machinenames.ID
Order By
oee_machinenames.ID)
Group By
oee_main_interim.NAME, oee_machinenames.Name, voee_mach_shifts.curr_Shift
Order By
oee_system.oee_main_interim.NAME
什麼是'oee_main_interim.TS'類型 – vhu
這是一個時間戳 – elstiv