0
我得到了這個php,我需要從查詢的第一部分提供的值中獲得一些KPI,但它們只給出之前給出的名稱並且沒有值。我需要從選擇的las部分改變以獲取值而不是名稱?sq服務器,查詢考慮從「as」列的值
SELECT hist_eqmtlist.unit,
hist_statusevents.eqmt,
hist_exproot.shiftdate,
sum(case when hist_statusevents.category =1 then (hist_statusevents.duration/3600) else 0 end) as 'Efectivo',
sum(case when hist_statusevents.category =2 then (hist_statusevents.duration/3600) else 0 end) as 'Demora',
sum(case when hist_statusevents.category =3 then (hist_statusevents.duration/3600) else 0 end) as 'Reserva',
sum(case when hist_statusevents.category =4 then (hist_statusevents.duration/3600) else 0 end) as 'Mantencion',
sum(case when hist_statusevents.category =5 then (hist_statusevents.duration/3600) else 0 end) as 'Averia',
sum(case when hist_statusevents.category =6 then (hist_statusevents.duration/3600) else 0 end) as 'Accidente'
(Efectivo+Demora+Reserva)/(Efectivo+Demora+Reserva+Mantencion+Averia+Accidente) as 'Disp. Fisica'
FROM hist_eqmtlist,hist_exproot,hist_statusevents
WHERE hist_exproot.shiftindex = hist_statusevents.shiftindex And hist_statusevents.shiftindex = hist_eqmtlist.shiftindex And hist_statusevents.eqmt = hist_eqmtlist.eqmtid And hist_eqmtlist.unit='Dozer ' AND hist_exproot.shiftdate='2011-01-02'
GROUP BY hist_statusevents.eqmt, hist_exproot.shiftdate, hist_eqmtlist.unit
order by hist_exproot.shiftdate,hist_statusevents.eqmt
我將編輯查詢,因爲它沒有工作 – Pipebritop
'它沒有work'是一個非常模糊的術語,什麼也沒有確切地工作?你有錯誤信息?它沒有顯示你期望的結果?或者是其他東西 ???? –
ahhh現在明白了! – Pipebritop