t8.sql 473 B

12345678910
  1. SELECT bpu.id, bpu.useForm, pus.checkoutNumber, pus.quitNumber FROM
  2. bigpartuse bpu
  3. INNER JOIN (SELECT SUM(pu.checkoutNumber) checkoutNumber,SUM(pu.quitNumber)quitNumber, pu.bigId FROM partuse pu GROUP BY pu.bigId)pus
  4. ON pus.bigId =bpu.`id`
  5. WHERE bpu.pastureId=304
  6. and bpu.`useForm` LIKE CONCAT('%','CK19220907007','%')
  7. -- AND bpu.`useType` <>4 AND pus.quitNumber < pus.checkoutNumber
  8. ORDER BY bpu.`useForm` desc
  9. select * from bigpartuse where useForm ='CK19220907007'