473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

T-SQL : How to find cross-conditional queries?

I have following question for you. If you are unable to provide me with an answer... could you please tell me the keywords/search string I would need to use in order to Google this issue?

Table_1_Debits:

Dnum DbCrInd Abbreviation
-------- ----------- ------------------
8261 DB SALES
8261 DB INTER
8261 DB INTER
8261 DB AR
0414 DB AR
3662 DB AR
3662 DB AR

Table_2_Credits:

Dnum DbCrInd Abbreviation
-------- ------------ ------------------
8261 CR SALES
8261 CR SALES
8261 CR AR
8261 CR INTER
0414 CR SALES
3662 CR SALES
3662 CR SALES

From the above two tables, I am looking for a query that will return Dnum only ONCE if the following condition exists:

(DB=AR AND CR=SALES) AND (DB<>COS OR CR<>INV) AND (DB<>INTER OR CR<>INTER)

Please note: In Table_1_Debits and Table_2_Credits, we do have DB=INTER and also CR=INTER for Dnum 8261. So, the query should not return any rows for Dnum 8261. However, for Dnum 0414 and 3662 the query should return rows or the value of Dnum. I am using SQL Server 2000 on windows.

I have tried everything I know. I guess the problem is I do not know how to perform cross comparisons within each Dnum for CR and DB values using a query!

Harry.SQLserver@gmail.com
Nov 18 '07 #1
0 848

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
5
by: My SQL | last post by:
Hi, I started the general query log with mysqld --log On my machine this command works fine and every select, update and all statements are logged. I tried the same command on another...
7
by: Dana Shields | last post by:
I am attempting to upsize from access to SQL Server. I'm trying to convert my queries to SQL Server views; however, I'm having a lot of difficulty with the syntax differences. For instance, a...
6
by: Hennie7863 | last post by:
Hi everybody, After days reading stuff about indexing, extents, pages, 8KB, 64 KB, IGNORE_DUP_KEY, CREATE INDEX, bla bla, lalalala, lllllll, grrrrrrr and testing with different kinds of queries,...
4
by: roman.ali | last post by:
Hi, I am using a .dqy file to import some rows from a sql server 2003 database to microsoft excel. Unfortunately, I have am importing more rows than excel can handle. Is there a way around...
7
by: Filips Benoit | last post by:
Dear all, Tables: COMPANY: COM_ID, COM_NAME, ..... PROPERTY: PRP_ID, PRP_NAME, PRP_DATATYPE_ID, PRP_DEFAULT_VALUE ( nvarchar) COMPANY_PROPERTY: CPROP_COM_ID, CPROP_PRP_ID, CPROP_VALUE...
3
by: hedgracer | last post by:
Is there any way to generate a list of access queries in an access database which utilize a specific table? Thanks for all help in advance. Dave C.
4
by: eeb4u | last post by:
I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and currently running queries to get counts on tables etc. When running SELECT queries I notice that the data returns and I have to...
2
by: Simon | last post by:
Dear reader, Is there a tool available to check the necessity of a Query. Queries are used in Forms and Reports. It can be that a Form or Report is not longer required and will be deleted....
0
by: elimeli1 | last post by:
Hi. I am writing a small monitoring tool for our operators that can monitor our DB2 databases in the organization. I know there are plenty of tools out there but I need something very customized that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.