sql - Display all fields regardless if total is zero -
i have 4 tables:
- requestpossibility fields id, requestid, text
- requestcategory fields text, requestid
- requestoutcome fields id, requestid
- request field requestid
here query returns results when "total" not 0. want return results type "text". here query:
select max(rc.text) text, max(rp.text) textpossibility, count(*) total request r join requestoutcome ro on r.requestid = ro.id join requestpossibility rp on ro.id = rp.id join requestcategory rc on rp.requestid = rc.requestid group rp.id order 1, 2 asc
if count specific field , use left join might resolve this.
select max(rc.text) text, max(rp.text) textpossibility, count(r.requestid) total request r left join requestoutcome ro on r.requestid = ro.id join requestpossibility rp on ro.id = rp.id join requestcategory rc on rp.requestid = rc.requestid group rp.id order 1, 2 asc
Comments
Post a Comment