I have two tables with 13 columns of values each - e.g. week1, week2,
week3...week13.
I want to check if any (t1.week1 > 0 AND t2.week1 > 0) or (t1.week2 >
0 AND t2.week2 > 0), and so on...
In fact, the where clause currently looks like:
3 where (f.week1 > 0 and o.week1 > 0)
4 or (f.week2 > 0 and o.week2 > 0)
5 or (f.week3 > 0 and o.week3 > 0)...
I also would like to be able to somehow identify the weeks in question
- it could be week1 for part1, week4 for part2, and weeks3 and 12 for
part3.
Currently, I have a huge statement like above, where it AND's the
similar weeks, and OR's each weekly comparison step. The table only
has 2892 rows, and I am getting 45871 rows returned from my sql.
Thanks for any assistance!!! 3 6653 ri***********@yahoo.com (Richard Brust) wrote in message news:<8b**************************@posting.google. com>... I have two tables with 13 columns of values each - e.g. week1, week2, week3...week13.
I want to check if any (t1.week1 > 0 AND t2.week1 > 0) or (t1.week2 > 0 AND t2.week2 > 0), and so on...
In fact, the where clause currently looks like: 3 where (f.week1 > 0 and o.week1 > 0) 4 or (f.week2 > 0 and o.week2 > 0) 5 or (f.week3 > 0 and o.week3 > 0)...
I also would like to be able to somehow identify the weeks in question - it could be week1 for part1, week4 for part2, and weeks3 and 12 for part3.
Currently, I have a huge statement like above, where it AND's the similar weeks, and OR's each weekly comparison step. The table only has 2892 rows, and I am getting 45871 rows returned from my sql.
Thanks for any assistance!!!
Richard, You mention two tables at the start of your post, are you
referencing both tables in the same SQL. If so, how are your joining
the tables? You are probably missing a join condition or should be
using a UNION.
In general when you mix AND and OR clauses in the WHERE clause you
need to group various conditions with parenthesis to prevent
unexpected comparisons.
Example: where ( (f.week1 > 0 and o.week1 > 0) or (..) or (..) )
AND/OR (..)
HTH -- Mark D Powell -- Ma*********@eds.com (Mark D Powell) wrote in message news:<26**************************@posting.google. com>... ri***********@yahoo.com (Richard Brust) wrote in message news:<8b**************************@posting.google. com>... I have two tables with 13 columns of values each - e.g. week1, week2, week3...week13.
I want to check if any (t1.week1 > 0 AND t2.week1 > 0) or (t1.week2 > 0 AND t2.week2 > 0), and so on...
In fact, the where clause currently looks like: 3 where (f.week1 > 0 and o.week1 > 0) 4 or (f.week2 > 0 and o.week2 > 0) 5 or (f.week3 > 0 and o.week3 > 0)...
I also would like to be able to somehow identify the weeks in question - it could be week1 for part1, week4 for part2, and weeks3 and 12 for part3.
Currently, I have a huge statement like above, where it AND's the similar weeks, and OR's each weekly comparison step. The table only has 2892 rows, and I am getting 45871 rows returned from my sql.
Thanks for any assistance!!!
Richard, You mention two tables at the start of your post, are you referencing both tables in the same SQL. If so, how are your joining the tables? You are probably missing a join condition or should be using a UNION.
In general when you mix AND and OR clauses in the WHERE clause you need to group various conditions with parenthesis to prevent unexpected comparisons. Example: where ( (f.week1 > 0 and o.week1 > 0) or (..) or (..) ) AND/OR (..)
HTH -- Mark D Powell --
Mark -
You are right in both cases:
+ I am using a UNION, and
+ I added second set of parens surrounding the entire AND/OR block,
and it worked fine. Your 'Example:' above is exactly how it looks
now, and returns the expected rows.
Thanks for taking the time to post! ri***********@yahoo.com (Richard Brust) wrote in message news:<8b**************************@posting.google. com>... Ma*********@eds.com (Mark D Powell) wrote in message news:<26**************************@posting.google. com>... ri***********@yahoo.com (Richard Brust) wrote in message news:<8b**************************@posting.google. com>... I have two tables with 13 columns of values each - e.g. week1, week2, week3...week13.
I want to check if any (t1.week1 > 0 AND t2.week1 > 0) or (t1.week2 > 0 AND t2.week2 > 0), and so on...
In fact, the where clause currently looks like: 3 where (f.week1 > 0 and o.week1 > 0) 4 or (f.week2 > 0 and o.week2 > 0) 5 or (f.week3 > 0 and o.week3 > 0)...
I also would like to be able to somehow identify the weeks in question - it could be week1 for part1, week4 for part2, and weeks3 and 12 for part3.
Currently, I have a huge statement like above, where it AND's the similar weeks, and OR's each weekly comparison step. The table only has 2892 rows, and I am getting 45871 rows returned from my sql.
Thanks for any assistance!!!
Richard, You mention two tables at the start of your post, are you referencing both tables in the same SQL. If so, how are your joining the tables? You are probably missing a join condition or should be using a UNION.
In general when you mix AND and OR clauses in the WHERE clause you need to group various conditions with parenthesis to prevent unexpected comparisons. Example: where ( (f.week1 > 0 and o.week1 > 0) or (..) or (..) ) AND/OR (..)
HTH -- Mark D Powell -- Mark -
You are right in both cases:
+ I am using a UNION, and + I added second set of parens surrounding the entire AND/OR block, and it worked fine. Your 'Example:' above is exactly how it looks now, and returns the expected rows.
Thanks for taking the time to post!
Glad to have been of help. -- Mark -- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: xixi |
last post by:
we are using db2 udb v8.1 on windows, i would like to know whether we
have tool or way to compare two tables on same database for data
difference. thanks. (same ddl, different data, try to compare...
|
by: Maur |
last post by:
Hi all,
I have 2 tables say t_OLD and t_NEW. The new has
corrections for audit purposes.
They are identical in all respects (i.e. new is a copy of
old and then changes are made to t_new)
...
|
by: Megan |
last post by:
Hi everybody-
I'm helping a friend with a music database. She has an old one and is
creating a new one. She wants to compare records and fields in the old
database with records and fields in the...
|
by: Ken Smith |
last post by:
Can someone tell me how to do a compare of two different fields in two
different tables to generate a report which will tell me what values are
missing?
I have two tables, one is the values that...
|
by: Stephen |
last post by:
I am trying to compare the tables in two similar databases using the SQLDMO
object. I am able to use this object to access different SQL servers and
choose two different databases. The versions of...
|
by: Mark |
last post by:
by m.r.davies
I have 2 tables on seperate Db's (and servers)
I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB
when i have...
|
by: rcolby |
last post by:
Evening,
Wondering if someone can point me in the right direction, on how I would
compare a system.guid with a system.byte.
system.guid (pulled from sql server table with a data type of...
|
by: mcolson |
last post by:
I am trying to compare the last two values in the same column of a
table. First of all, I have a column titled Row_Index that uses an
index which starts at 1 and increments by 1. What I am trying...
|
by: lucianone41 |
last post by:
Hello everyone, I´m starting to learn Access , SQL and a bit of VB.
My problem is the following: I have two tables, one of them contains the records for missing points on a GPS system (called the...
|
by: napatel04 |
last post by:
Hi everyone,
I would like to know if there is a quick query someone can help me
write for the following scenario. I think I can do this with VBA but
since this is suppose to be a temp. solution,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |