Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select record if any field is negative

Status
Not open for further replies.

Wes1961

Technical User
Aug 21, 2001
72
US
I want to write a query that will return a record if any field in that record is negative.

The table looks sorta like this:

Item Bal1 Bal2 Bal3 Bal4...Bal24

How can I do this?
 
I'm assuming your field names represent account balances? I think you may want to rething how you are storing your data. Looks like you may have a problem with repeating groups as columns.

But if you must do it this way then you would have to run a series of OR statements to get what you want.

SELECT *
FROM tablename
WHERE Bal1 < 0 Or Bal< 0...etc

This is very inefficient.

I'd create an item table and balance table and link them by an item id or something.
 
I agree on the inefficency but I 'inherited' this database and was asked to write a 'quick' report for someone. I do need to rewrite/change several things in this database but do not have the time right now since this table is already used in many queries. I was just lookng for a quick way to select the info for the report.

I did not completely discribe my problem. It gets more complicated as I need to change the filter based on the supplier. Sometimes I need to only select records if a negative accurs in the first 13, next time it might be 18.

Ven Item Bal1...
HOV 1A -100
STG 2B 20

Thanks anyway for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top