sosamv
asked on
Max and Group by Query
I have the following indicators table:
ID_Indicator INT Auto_Increment
ID_Type INT (Foreign Key)
Value VARCHAR
Month INT
Year INT
ID_Localization INT
I need to pull up the most recent indicators for each type, based on the month and year fields, how can i do this?? i have tried:
SELECT ID_Indicator,ID_Type, MAX(DATE(CONCAT(Year,'/',M onth,'/',' 01'))), value
FROM tbldatolocalizacion
WHERE ID_Localization = 17
GROUP BY ID_Type
it brings me 2 field but not the latest =(
Any clues?
Thanx, jerry
ID_Indicator INT Auto_Increment
ID_Type INT (Foreign Key)
Value VARCHAR
Month INT
Year INT
ID_Localization INT
I need to pull up the most recent indicators for each type, based on the month and year fields, how can i do this?? i have tried:
SELECT ID_Indicator,ID_Type, MAX(DATE(CONCAT(Year,'/',M
FROM tbldatolocalizacion
WHERE ID_Localization = 17
GROUP BY ID_Type
it brings me 2 field but not the latest =(
Any clues?
Thanx, jerry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
#CRAZY QUERY
SELECT ut.ID_DatoLocalizacion,dat
FROM tbldatolocalizacion as ut
inner join tbldato dato ON dato.ID_Dato = ut.ID_Dato
WHERE DATE(CONCAT(Ano,'-',Mes,'-
AND ID_Localizacion=17 AND dato.ShowPaginaPrincipal = 1 AND dato.IsPublic = 1
Thats working perfect!
Thanx