S
SmokyMtnzz
Hello everyone,
I would have thought that this query would be very, very simple to
create, but I'm having problems. I want to return the very last dated
PTC of each item. As you can see below, I get EVERY entry of Item, not
just the maximum dated one. So, I don't want to see the Item 106
$1.29 because it is not the last MaxOfPTCChgDate. Same with the item
125 $1.29. 101, 102, 103, etc. are ok because there is only one entry
listed. (For simplicity I pulled my data from PTC Query into another
query, instead of pulling from an actual table.)
CustID Item PTC MaxOfPTCChgDate
01813 101 $5.59 7/11/2005
01813 102 $6.39 7/11/2005
01813 103 $8.99 7/11/2005
01813 106 $1.29 7/11/2005
01813 106 $1.59 7/12/2005
01813 107 $14.99 7/11/2005
01813 113 $5.59 7/11/2005
01813 114 $8.99 7/11/2005
01813 125 $1.29 7/12/2005
01813 125 $1.39 7/11/2005
SELECT [PTC Query].CustID, [PTC Query].Item, [PTC Query].PTC, Max([PTC
Query].PTCChgDate) AS MaxOfPTCChgDate
FROM [PTC Query]
GROUP BY [PTC Query].CustID, [PTC Query].Item, [PTC Query].PTC
HAVING ((([PTC Query].CustID)="01813"))
ORDER BY [PTC Query].Item;
Above is the sql that I am using. Please let me know what I'm doing
wrong so I can learn more about sql.
Thank you for any help you can provide.
Bob
I would have thought that this query would be very, very simple to
create, but I'm having problems. I want to return the very last dated
PTC of each item. As you can see below, I get EVERY entry of Item, not
just the maximum dated one. So, I don't want to see the Item 106
$1.29 because it is not the last MaxOfPTCChgDate. Same with the item
125 $1.29. 101, 102, 103, etc. are ok because there is only one entry
listed. (For simplicity I pulled my data from PTC Query into another
query, instead of pulling from an actual table.)
CustID Item PTC MaxOfPTCChgDate
01813 101 $5.59 7/11/2005
01813 102 $6.39 7/11/2005
01813 103 $8.99 7/11/2005
01813 106 $1.29 7/11/2005
01813 106 $1.59 7/12/2005
01813 107 $14.99 7/11/2005
01813 113 $5.59 7/11/2005
01813 114 $8.99 7/11/2005
01813 125 $1.29 7/12/2005
01813 125 $1.39 7/11/2005
SELECT [PTC Query].CustID, [PTC Query].Item, [PTC Query].PTC, Max([PTC
Query].PTCChgDate) AS MaxOfPTCChgDate
FROM [PTC Query]
GROUP BY [PTC Query].CustID, [PTC Query].Item, [PTC Query].PTC
HAVING ((([PTC Query].CustID)="01813"))
ORDER BY [PTC Query].Item;
Above is the sql that I am using. Please let me know what I'm doing
wrong so I can learn more about sql.
Thank you for any help you can provide.
Bob