•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 391,635 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,785 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 455 | Replies: 1
![]() |
•
•
Join Date: Aug 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have to write a view that will return all invoices, but with the contact person of the last invoice issued for the same product.
It is hard to explain so I will try to show on example:
Table1: "Invoice"
Table2: "Invoice_row"
Table3: "Contacts"
Each Invoice record contains Contact_id field which points to the contact person who order it.
Each Invoice_row record contains product information.
Products are based on codes (1100, 1101, ...) and to make things a bit harder, products have updates which have the same base number: 110001, 110002, 110101, ...
I would like to get:
Company, Product, Contact, InvoiceNo, InvoiceDate
I can get this with the contact person stated on the individual invoice record, but I don't know how to get the last contact person for each product:
If John ordered 1100 and then Jane ordered 110001 (which is the update to 1100 and both of them are contacts for them same company) I would like to get:
InvoiceNo 1, Product 1100, Contact person Jane
InvoiceNo 2, Product 110001, Contact person Jane
Makes any sense? I want Jane to be returned for all records.
I realy need this so I would appreciate any help.
If something is not clear I will try to explain again.
-thanks
It is hard to explain so I will try to show on example:
Table1: "Invoice"
Table2: "Invoice_row"
Table3: "Contacts"
Each Invoice record contains Contact_id field which points to the contact person who order it.
Each Invoice_row record contains product information.
Products are based on codes (1100, 1101, ...) and to make things a bit harder, products have updates which have the same base number: 110001, 110002, 110101, ...
I would like to get:
Company, Product, Contact, InvoiceNo, InvoiceDate
I can get this with the contact person stated on the individual invoice record, but I don't know how to get the last contact person for each product:
If John ordered 1100 and then Jane ordered 110001 (which is the update to 1100 and both of them are contacts for them same company) I would like to get:
InvoiceNo 1, Product 1100, Contact person Jane
InvoiceNo 2, Product 110001, Contact person Jane
Makes any sense? I want Jane to be returned for all records.
I realy need this so I would appreciate any help.
If something is not clear I will try to explain again.
-thanks
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
- Product List and Order Form Submit (JavaScript / DHTML / AJAX)
- What should I charge? (eCommerce)
- Help with asp form will not display contact information (ASP)
- Hotmail Login (Windows NT / 2000 / XP / 2003)
Other Threads in the MS SQL Forum
- Previous Thread: Replication Issues
- Next Thread: UPDATE rows WHERE array[] ?


Linear Mode