这就是我正在做的事情
SELECT * FROM pacient_export WHERE(idpacient_nit IN(SELECT idpacient FROM treatment WHERE date_treatment< CURDATE() - INTERVAL 180天)或idpacient_nit IN(SELECT idpacient FROM report7))AND idpacient_nit IN(SELECT idpacient FROM report7 WHERE charge< 50)
SELECT * FROM pacient_export WHERE(idpacient_nit IN(SELECT idpacient FROM treatment WHERE date_treatment< CURDATE() - INTERVAL 180天)或idpacient_nit IN(SELECT idpacient FROM report7))AND idpacient_nit IN(SELECT idpacient FROM report7 WHERE charge> = 50)
问题是,在表格 report7 中,pacient可能会多次显示,它会多次选择相同的pacient ...如何选择最低费用值在每个pacient的表 report7 中?
For example
table: report7
pacient | charge
101 | 32
101 | 92
Results:
pacient | charge
101 | 32
谢谢!