Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Unanswered: Using Derived Column in Where Condition

    I am making queries using VBA in Access.

    I have one query temp3 that returns several records with columns ID, Diff etc.

    I would like to filter the results of temp3 further using the condition temp3.[Diff] <> 0

    I could not use this condition within temp3 because Diff is a derived column.

    So I making another query temp4 as below:

    SELECT * FROM temp3
    WHERE temp3.[Diff] <> 0;

    When I run this Query, the records filter correctly. However, the Diff column is blank for all records.

    What am I doing wrong here?

    I also tried nesting temp 3 as below and get the same issue:

    select * from( Query temp3) as data where data.diff <> 0

    Can you please help me with this?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by anunat View Post
    I could not use this condition within temp3 because Diff is a derived column.
    If the original query (temp3) computes [Diff] such as:
    Code:
    SELECT..., <Column2> - <Column1> AS Diff
    You can filter the resulting data set in the same query using:
    Code:
    WHERE ((<Column2> - <Column1>) <> 0)
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •