join - SQL query with multiple where clause -


i'm trying write query dataset in ssrs. have joining table called requestschools links 3 other tables:

  1. schools
  2. placing request
  3. 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 

sql query results

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

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -