If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to make a query to compare values in different columns?
I'm trying to figure out if there is a way to run a query that will compare
the values in column 5, based on the values in column 2. In column two the values are a person ID number, and that number can be repeated on multiple rows. The values in column 5 are dollar amounts. The dollar amounts for each persons ID should be the same, but they all aren't. I want to run a query that compares the dollar amounts in column 5 for each person's ID number, and tells me if one of the dollar amounts is not equal. Is there a way to do that? I'm still very new to databases, so I don't know much about making these things. -- Brendan |
#2
|
|||
|
|||
SELECT MyTable.ID, MyTable.Dollars
FROM MyTable INNER JOIN MyTable As MyTable_1 ON MyTable.ID = MyTable_1.ID WHERE MyTable.Dollars MyTable_1.Dollars To build this on the query grid, add two copies of the table in the top part of the query and drag and drop the ID field from one to the other to create the INNER JOIN. Add ID and Dollars from the first copy of the table and put on the Criteria line: MyTable_1.Dollars ... where MyTable is the name of the table and "Dollars" is the name of the dollar field. -- John Viescas, author "Building Microsoft Access Applications" "Microsoft Office Access 2003 Inside Out" "Running Microsoft Access 2000" "SQL Queries for Mere Mortals" http://www.viescas.com/ (Microsoft Access MVP since 1993) "Murph" wrote in message ... I'm trying to figure out if there is a way to run a query that will compare the values in column 5, based on the values in column 2. In column two the values are a person ID number, and that number can be repeated on multiple rows. The values in column 5 are dollar amounts. The dollar amounts for each persons ID should be the same, but they all aren't. I want to run a query that compares the dollar amounts in column 5 for each person's ID number, and tells me if one of the dollar amounts is not equal. Is there a way to do that? I'm still very new to databases, so I don't know much about making these things. -- Brendan |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Update Query from table with wildcard values | Ross | Running & Setting Up Queries | 4 | February 16th, 2005 03:50 AM |
Could I get some query theory clarification? | Dennis Snelgrove | Running & Setting Up Queries | 3 | November 27th, 2004 11:13 PM |
Counting unique values and all values in same query | John Morrissey | Running & Setting Up Queries | 1 | August 6th, 2004 12:14 PM |
cant think of the query... | Dragon | Running & Setting Up Queries | 5 | July 21st, 2004 06:25 PM |
Newbie? Do I use Report or Query | John Egan | New Users | 11 | June 28th, 2004 08:31 PM |