K
knavlekar
I have four tables. I have not included all the fields and all the tables
but the fields that I thought that are important for the query.
1) Orders:
Order ID (P.K)
Customer ID (F.K)
Order Date
Ship Address
Ship Date
2) Order Details:
Order Detail ID (PK)
Order ID (FK)
Product ID (FK)
Qty .
Unit Price
3) Payments:
Payment ID (PK)
Order ID (FK)
Payment Amount
Payment Date
4) Customers:
Customer ID (PK)
Company Name
I want to create a query which returns
Company Name, Product ID, Order ID, Ship Date, Payment ID, Payment Date,
Payment Amount
(Note: For some Order ID there are multiple records because in a single
order we sale more than one products)
At present when I create a query it returns duplicate values for Payment ID,
Payment Date, and Payment Amount. I want unique results for the fields from
payment tables.
I understand why it happens but I can not solve it.
Reason according to me:
Every Order ID in Payments table is present in Orders table.
But not every Order ID in Orders table is present in Payments table as there
may be some orders for which the payments are still pending.
In short
I want all the entries for order tables and unique values for payment table
and ultimately I want to create a report.
I hope I have explained the problem.
Thanks for the help in advance.
-Kedar.
but the fields that I thought that are important for the query.
1) Orders:
Order ID (P.K)
Customer ID (F.K)
Order Date
Ship Address
Ship Date
2) Order Details:
Order Detail ID (PK)
Order ID (FK)
Product ID (FK)
Qty .
Unit Price
3) Payments:
Payment ID (PK)
Order ID (FK)
Payment Amount
Payment Date
4) Customers:
Customer ID (PK)
Company Name
I want to create a query which returns
Company Name, Product ID, Order ID, Ship Date, Payment ID, Payment Date,
Payment Amount
(Note: For some Order ID there are multiple records because in a single
order we sale more than one products)
At present when I create a query it returns duplicate values for Payment ID,
Payment Date, and Payment Amount. I want unique results for the fields from
payment tables.
I understand why it happens but I can not solve it.
Reason according to me:
Every Order ID in Payments table is present in Orders table.
But not every Order ID in Orders table is present in Payments table as there
may be some orders for which the payments are still pending.
In short
I want all the entries for order tables and unique values for payment table
and ultimately I want to create a report.
I hope I have explained the problem.
Thanks for the help in advance.
-Kedar.