473,503 Members | 5,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP - Retrieve last payment date in table wrong output

6 New Member
Here is my SQL I am getting the information but should only see 1 record per vendor ID I only want to see the max date.

What am I missing to reduce the mulitple lines for this output.
Thanks.

Example:
Vendor ID 12 with date of 22-DEC-06.
Expand|Select|Wrap|Line Numbers
  1. SQL> select hdr.vendor_id, hdr.vendor_INVOICE_ID, max(pmt.pay_date) AS LAST_PAYMENT_DATE
  2.   2  FROM mil_vendor_invoice_payment_mt pmt RIGHT OUTER JOIN  mil_vendor_invoice_mt hdr
  3.   3  ON hdr.vendor_invoice_ID = pmt.vendor_INVOICE_ID
  4.   4  GROUP BY hdr.vendor_id, hdr.vendor_invoice_ID;
  5.  
  6.  VENDOR_ID VENDOR_INVOICE_ID LAST_PAYM
  7. ---------- ----------------- ---------
  8.         10                 4
  9.         10                 5
  10.         12                 1 20-DEC-06
  11.         12                 2 22-DEC-06
  12.         12                 3
  13.         45                 6
  14.         45                 7
  15.  
Dec 26 '06 #1
3 1428
ronverdonk
4,258 Recognized Expert Specialist
This one is different from your previous post. Now you are using 2 tables instead of 1 only.

So show us the table descriptions. AND: is the actual content of your date field '22-DEC-2006', i.e. is it a char type field and not a date or datetime type field?

Ronald :cool:
Dec 26 '06 #2
rlbSQL
6 New Member
This one is different from your previous post. Now you are using 2 tables instead of 1 only.

So show us the table descriptions. AND: is the actual content of your date field '22-DEC-2006', i.e. is it a char type field and not a date or datetime type field?

Ronald :cool:

I just got it Ronald.
I needed to set my group by to the vendor_id and it worked. I am new to using SQL and have been assigned some reports to do that will take some thinking so I will probably be coming back for questions.

Thank You for responding so quickly.
Dec 26 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
You are welcome.

Ronald :cool:
Dec 27 '06 #4

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

Similar topics

0
1907
by: MSM | last post by:
Hello, This may be posted twice if so i apologize. I am creating a form using php where the information entered into the form will go into a database. When creating the tables in SQL where do I...
3
1992
by: MAB | last post by:
I have a table Create Table Payments { paymentid int, customerid int, amount int, date datetime } What I want is the sum of the amounts of the last payments of all customers.
18
12780
by: Jeremy Weiss | last post by:
I'm trying to build a database that will handle the monthly billing needs of a small company. I'm charting everything out and here's what I see: table for customers sub table to track payments...
6
1678
by: Welie | last post by:
I am having a problem an it's driving me crazy, I hope someone can correct my technique. I can't find a pattern and don't know where to look to debug this. The problem is on a continuous form, the...
2
1832
by: Rlcohen70 | last post by:
Hello, I have two tables that have a relationship based on a customer ID. The first table Customer has: Customer ID Name Address etc Accounts Table has: Customer ID
4
1808
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
3
1760
by: rlbSQL | last post by:
I am trying to find the last payment date made to a vendor in a table. This table has many vendors I will need to have a line for each vendor and what thier last payment date is. I assume it...
4
2095
by: kjflash | last post by:
Hi, Let's say I have a table containing payment information: CustID, PaymentDate, PaymentAmount. Here is some sample data: CustID Date Amount 01 ...
1
2687
by: myemail.an | last post by:
Hi all, I am a novice to Access, and was wondering if I could get some help on a problem I can't solve. I have a database with customer payments, structured like this: customer code type of...
0
7316
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
7449
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...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.