Results 1 to 7 of 7
  1. #1
    Schon731 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    19

    Show only rows where fielda < fieldb


    Thats about it. I have 5 columns that I want to display but only if fielda is less than fieldb. The query is coming from a linked table where those table fields are numberic (double). Sounds easy but for a layman its not. Please help.

    Have tried
    Where [Fielda]<[fieldb] and things along those lines but still nothing.. Thanks

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Can you provide the full SQL text of the query (switch to SQL view to get the text)?

  3. #3
    Schon731 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    19
    SELECT DG572B.[DG-Drug Code], DG572B.[DG-Drug Name], DG572B.[DL-Acq Unit Cost], DG572B.[DL-Welfare Unit Cost], [DG572B]![DL-Welfare Unit Cost]-[DG572B]![DL-Acq Unit Cost] AS Expr1
    FROM DG572B
    ORDER BY [DG572B]![DL-Welfare Unit Cost]-[DG572B]![DL-Acq Unit Cost];


    This is what I have now just so I can work with it. What I want is to only show a row for where DG572B.[DL-Acq Unit Cost] < DG572B.[DL-Welfare Unit Cost]

    I added the expr1 and sorted it so I can focus on the negative numbers.. Hope this helps..

  4. #4
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Assuming that fielda and fieldb correspond to DG572B.[DL-Acq Unit Cost]and DG572B.[DL-Welfare Unit Cost] respectively, the WHERE clause you showed earlier should work, so perhaps I am not understanding what you want to achieve

    Code:
    SELECT DG572B.[DG-Drug Code], DG572B.[DG-Drug Name], DG572B.[DL-Acq  Unit Cost], DG572B.[DL-Welfare Unit Cost], [DG572B].[DL-Welfare Unit  Cost]-[DG572B].[DL-Acq Unit Cost] AS Expr1
    FROM DG572B
      WHERE DG572B.[DL-Acq Unit Cost] < DG572B.[DL-Welfare Unit Cost]
    ORDER BY [DG572B]![DL-Welfare Unit Cost]-[DG572B]![DL-Acq Unit Cost];

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I guess that Schon tried to put where clause after order clause, that's not the right syntax.

  6. #6
    Schon731 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    19
    Told u I was a layman at this. My problem was I was putting the word WHERE into the criteria so it was coming up as WHERE "where....etc.. I just removed that word and it worked. Looking at your SQL view helped, thanks alot..

  7. #7
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. I'm glad you got it worked out.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-17-2010, 02:49 PM
  2. combine rows
    By summerAIS in forum Queries
    Replies: 3
    Last Post: 07-31-2010, 10:13 PM
  3. Replies: 3
    Last Post: 07-08-2010, 01:47 PM
  4. Crushing Rows
    By SCFM in forum Access
    Replies: 4
    Last Post: 03-02-2010, 09:10 AM
  5. Queries the max from two rows
    By mohsin74 in forum Queries
    Replies: 0
    Last Post: 12-15-2006, 12:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums