SQL selecting a single record by comparing the different fields
My problem is the foll开发者_如何学编程owing..
The help that I need is to only SELECT when both prp_response <> 1 for each of prp_hist_id so it will list those ones (DISTINCT)
For example in this case will only SELECT only the prp_hist_id = 21 since both prp_response <> 1
Hope I was clear enough and any help would be greatly appreciated. Thank you.
SELECT DISTINCT prp_hist_id
FROM tbl_proposal_workload
WHERE prp_hist_id NOT IN ( SELECT prp_hist_id FROM tbl_proposal_workload WHERE prp_response = 1 )
A possible answer, but specific to your case is the use of GROUP
to choose diferent values and HAVING
to discard the case that contain the prp_reponse=1
SELECT prp_hist_id
FROM tbl_proposal_workload
GROUP BY prp_hist_id
HAVING MIN(prp_response)<>1
Hope it helps!
精彩评论