So I have a table that has n rows like this:
.ID.|.Cycle.|.Week.|..Date...|.Type.
.1..|...1...|..1...|.12-12-12|.a.
.2..|...1...|..2...|.12-12-12|.a.
.3..|...1...|..3...|.12-12-12|.a.
.4..|...1...|..4...|.12-12-12|.a.
.5..|...2...|..1...|.12-12-12|.a.
.6..|...2...|..2...|.12-12-12|.a.
.7..|...2...|..2...|.12-12-12|.some_value.
So here I'd want to get back cycle 2, week 2 of type "some_value" because cycle 2 is the largest cycle number in the table, and week 2 is the largest week number in cycle 2.
Right now I use query
SELECT cycle=MAX(cycle),week=MAX(week)
FROM table
WHERE TYPE=some_value
But I have a feeling this isn't right because I don't seem to get correct values. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire