Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Digital Lifestyle
Web Design and Hosting
SQL: HAVING question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="xstep" data-source="post: 776023" data-attributes="member: 11647"><p>Here is one idea.</p><p></p><p>SELECT NAME FROM TABLEA AS A1</p><p>INNER JOIN TABLEB AS B1 ON TABLEA.ID=B1.ID</p><p> AND B1.STATUS='Y'</p><p>LEFT OUTER JOIN TABLEB AS B2 ON B1.ID=B2.ID</p><p> AND B2.STATUS='M'</p><p>WHERE B2.STATUS IS NULL</p><p>GROUP BY NAME</p><p></p><p></p><p>Before the where clause, the query is effectively returning the following record complex.</p><p></p><p>[CODE]</p><p>A1.NAME B1.STATUS B2.STATUS</p><p>------- --------- ------------</p><p>Bill Y NULL</p><p>Tom Y M</p><p>Steve Y NULL</p><p>[/CODE]</p><p></p><p>The where clause filters on those NULL values of B2.STATUS thereby excluding the status which is M.</p></blockquote><p></p>
[QUOTE="xstep, post: 776023, member: 11647"] Here is one idea. SELECT NAME FROM TABLEA AS A1 INNER JOIN TABLEB AS B1 ON TABLEA.ID=B1.ID AND B1.STATUS='Y' LEFT OUTER JOIN TABLEB AS B2 ON B1.ID=B2.ID AND B2.STATUS='M' WHERE B2.STATUS IS NULL GROUP BY NAME Before the where clause, the query is effectively returning the following record complex. [CODE] A1.NAME B1.STATUS B2.STATUS ------- --------- ------------ Bill Y NULL Tom Y M Steve Y NULL [/CODE] The where clause filters on those NULL values of B2.STATUS thereby excluding the status which is M. [/QUOTE]
Verification
Post reply
Forums
Digital Lifestyle
Web Design and Hosting
SQL: HAVING question
Top