Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Can I do this in a WHERE clause?


Message #1 by "Michelle Gorman" <michelle.gorman@p...> on Mon, 24 Feb 2003 21:25:32
I tried this option, and it works.  Thanks a lot for your help.


> Let's assume you have no RESOURCE_CD equal to '0'.  If you do, there 
must be
some value you can use outside of the domain of legal values for this; use
that instead in the ELSE clause of the CASE expression below.  Your query
would then be:

SELECT PROJECT_LOC_ABBR, RESOURCE_CD, PROJECT_NM, RESOURCE_NM
	FROM PROJECT_TIME_ADJUSTMENTS PTA INNER JOIN RESOURCE R
		ON PTA.RESOURCE_CD = R.RESOURCE_CD
WHERE PR.RESOURCE_CD <>
	CASE WHEN PTA.PROJECT_CD LIKE 'MER%' THEN 'CAN'
		ELSE 0 END
ORDER BY PROJECT_LOC_ABBR, PROJECT_NM, RESOURCE_NM;

I used the infix form of a JOIN; this is clearer to me as it does not
clutter up the WHERE clause and thus makes it easier to read. YMMV.

--
Jeff Mason              Custom Apps, Inc.
Jeff@c...




  Return to Index