Microsoft
Software
Hardware
Network
Question : Using SQL MAX Function
My goal is to retrieve only the most recent eventdate record for each company (id_company). In this first example, I'm seeing multiple records for both companies 12937 and 12933.
select id_event, id_company, updatedescription, eventdate
from events e
where e.id_company in (12937, 12933 )
and
(
(e.UpdateDescription = 'Rating Affirmed')
OR (e.UpdateDescription = 'Rating Assigned')
OR (e.UpdateDescription = 'Rating Change - Downgrade')
OR (e.UpdateDescription = 'Rating Change - Upgrade')
)
order by id_company;
In this example, I'm trying to pull only the most recent eventdate record for each company by using SELECT MAX(e2.EventDate). It mysteriously works for only one company (12937) by pulling only the max eventdate row but I get no records at all for 12933. Unfortunately, I'm using SQL 2000 so I can't use some of the newer SQL functions.
select id_event, id_company, updatedescription, eventdate
from events e
where ( e.eventdate =
(
select MAX(e2.EventDate)
from events e2
where e2.id_company = e.id_company
and
(
(e.UpdateDescription = 'Rating Affirmed')
OR (e.UpdateDescription = 'Rating Assigned')
OR (e.UpdateDescription = 'Rating Change - Downgrade')
OR (e.UpdateDescription = 'Rating Change - Upgrade')
)
)
)
and e.id_company in (12937, 12933 )
order by id_company, eventdate desc;
Answer : Using SQL MAX Function
"VESA 75 and 100 LCDs use 4mm screws with 0.7 pitch." as specified in the document ....
Random Solutions
Java SAX
filezilla "could not start transfer"
yum Install oracle-validated fails dependency on glibc
wpf
Gmail doesn't work with 2 different computers
Exchange 2010 setup.com /preparead fails
Regular Expression needed to parse a string of multiple colons and extract an element-revised
Not downloading Offline address book files. A server (URL) could not be located. 0X8004010F
Need Excel VBA macro code to projected next number in a row of numbers using least squares best fit
Why are Win 7 clients dropping connections, event 4634, laggy network, freezing clients