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.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > How to query comparing two field values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Aug 2009
Posts: 10
Red face How to query comparing two field values

What is the best way to run a query comparing the values of two fields. For example, in my inventory database, I have a quanity field and a minimum stock field. How would I run a query to see which records have less in the quantity field than in the minimum stock field and report those records only?
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: May 2009
Posts: 258
Something similar to the following should work:
Code:
SELECT * FROM table_name
WHERE qty_field<min_stock_field
Regards,

Ax
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Aug 2009
Posts: 10
Thank you, but you will have to forgive me. I don't have the foggiest idea where to plug in the code. I have only set up this database using "VERY" basic Access skills.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Aug 2009
Location: Up Nort' Wi
Posts: 140
You can either use the query builder: Queries tab, click new, right click on the grey portion and select "SQL View". Type in the query that was offered and click the red ! to test it. It'll open a tableview list of the records that meet the criteria.
You can also build reports to do this and use the SQL as a filter on the open report command.

Sam, good luck
__________________
Good, fast, cheap...Pick 2.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On