join - SQL query with multiple where clause -
i'm trying write query dataset in ssrs. have joining table called requestschools links 3 other tables:
- schools
- placing request
- requestschooltype
i want name of requestedschool (requestedschooltypeid = 3)
i want name of catchmentschool (requestschooltypeid = 1)
i've attached image of sql query can working requested school. want catchment school well. grateful this.
select pr.placingrequestid, s.name requestedschool placingrequests pr inner join requestschools rs on rs.placingrequestid = pr.placingrequestid join schools s on s.schoolid = rs.schoolid rs.requestschooltypeid = 3 
i'm not 100% sure correct, can't see schema, source data or full example of desired output, think might it:
select pr.placingrequestid, s.name requestedschool, cs.name catchmentschool placingrequests pr inner join requestschools rs on rs.placingrequestid = pr.placingrequestid inner join schools s on s.schoolid = rs.schoolid , rs.requestschooltypeid = 3 -- requested school inner join schools cs on cs.schoolid = rs.schoolid , rs.requestschooltypeid = 1 -- catchment school happy update if it's not meant, , can clarify question indicated.
Comments
Post a Comment