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
Get CPU Cores Amount
SBS 2003 to 2008 Migration Preparation Tool Error
How to get lightbox to show over Flash banner?
Installer error 2869 Windows 7
Vb.net RSA asymmetric encryption algorithm
HiJackThis Analysis. Also "NoIE4StubProcessing"
Moving WordPress Site - Page Not Found
Sorry, VMware GO doesn't currently support ESXi servers with multiple datastores.
Latest Vsphere client
SQLCommandBuilder - GetUpdateCommand, GetInsertCommand and GetDeleteCommand Questions