SQL Query - Returning One Specific Column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #61
    And just for fun, a version which is hopefully more readable and concise.
    It does use a subquery though :-
    Code:
    SELECT Name, W_Fields
    FROM (SELECT Name, [W1] & [W2] & [W3] & [W4] & [W5] & [W6] & [W7] & [W8] & [W9] As W_Fields
    FROM YoungAdults) AS subYoungAdults
    WHERE ((([W_Fields] Not Like "*08/*") And
    ([W_Fields] Not Like "*09/*") And
    ([W_Fields] Not Like "*10/*")) Or
    (IsNull([W_Fields])));
    It needs to be in a subquery as you can't reference the named field (W_Fields) in a WHERE clause. The subquery makes it part of the source data.

    Comment

    Working...