Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Find duplicates where data in parent and child match

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-25 : 12:24:40
Kent writes "I have a parent/child relationship between tables 1 and 2.

Table 1 (An "Order Master" table) has (among other things) columns called "CustomerNum" and "OrderAmt".

Table 2 (The "Order Detail" table) has the detail records that are associated with the parent.

Both tables have a field called "ordernumber" that links them.

I need a query that will find ordermaster records that have the same customer number, same order amount, and same NUMBER of detail records.

Example:
Order #12 was from Customer "ABC", has 4 detail lines and totaled "$123.45"
Order #13 was from Customer "ABC", has 5 detail lines and totaled "$123.45"
Order #14 was from Customer "ABC", has 4 detail lines and totaled "$78.34"
Order #15 was from Customer "XYZ", has 4 detail lines and totaled "$123.45"
Order #16 was from Customer "ABC", has 5 detail lines and totaled "$123.45"

Note: The number of detail lines is ***NOT*** a field in the master record, I have to get a count of the associated detail records to find it.

I want a query that reveals that Order #13 and #16 match.

Kobiashi Maru"
   

- Advertisement -