0
我是新來的MySQL/PHP領域,我自己學習。我想拉運物品的數據,這裏是查詢我使用: -MYSQL語句不顯示我正確的值域
select jobs.job_number, jobs.employee_end, jobs.qty_comp, jobs.`date`,SUM(jobs.scrap), SUM(jobs.job_time)
FROM jobs where jobs.job_number in (
SELECT j.job_number FROM jobs j
WHERE j.moved_to = 'shipped'
AND j.`date` BETWEEN '2016-11-28' AND '2016-12-02'
AND j.qty_comp > 0
)
GROUP BY jobs.job_number
我收到正確的SUM(scrap)
和SUM(job_time)
和job_numbers
,它沒有顯示我moved_to = 'shipped', qty_comp > 0
中的最後一項。它顯示job_number
的第一次掃描的第一個條目。
謝謝你的任何幫助和建議。
謝謝你的幫助 – flying23x
從(選擇jobs.job_number,SUM(jobs.scrap)中選擇a.job_number,b.employee_end,b.qty_comp,b.'date',a.job_scrap,a.job_time作爲job_scrap ,SUM(jobs.job_time)作爲job_time FROM作業where jobs.job_number in(SELECT j.job_number FROM jobs j WHERE j.moved_to ='shipped'AND j.date BETWEEN%s AND%s AND j.qty_comp> 0)GROUP BY jobs.job_number)作爲a,作業b其中a.job_number = b.job_number和b.moved_to ='shipment',b.date在%s AND%s和b.qty_comp> 0組之間b.job_number – flying23x
會升值它如果你能夠upvote或接受答案。謝謝。 –