sql query to bring back multiple results -



sql query to bring back multiple results -

i have database table next columns

id reviewstreamtypeid reviewertitletypeid reviewstreamreviewerordernumber 1 1 1 1 2 1 27 2 3 1 9 3 4 2 1 1 5 2 27 2 6 2 10 3 7 3 1 1 8 3 16 2 9 3 24 3

i'm trying write query gets of reviewstreamtypeid reviewertitletypeid = 1 , reviewstreamreviewerordernumber = 1 , reviewertitletypeid = 27 , reviewstreamreviewerordernumber = 2. i'm looking result set 1,2

this query wrote, doesn't work

select reviewstreamtypeid routing.reviewstreamreviewerorder (reviewertitletypeid = 1 , reviewstreamreviewerordernumber = 1) , (reviewertitletypeid = 27 , reviewstreamreviewerordernumber = 2 )

any ideas on how write query bring right results?

you want utilize aggregation , having clause:

select reviewstreamtypeid routing.reviewstreamreviewerorder grouping reviewstreamtypeid having sum(case when reviewertitletypeid = 1 , reviewstreamreviewerordernumber = 1 1 else 0 end) > 0 , sum(case when reviewertitletypeid = 27 , reviewstreamreviewerordernumber = 2 1 else 0 end) > 0;

sql

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -