Hi guys I'm a beginner at SQL so please bear with me.. :)
My question is as follows.
I got this table:
     DateTime         ID     Year    Month   Value    Cost
-------------------|------|--------|-------|-------|--------|
 1-1-2013 00:00:01 |  1   |  2013  |   1   |  30   |   90   |
 1-1-2013 00:01:01 |  1   |  2013  |   1   |  0    |   0    |
 1-1-2013 00:02:01 |  1   |  2013  |   1   |  1    |   3    |
 1-2-2013 00:00:01 |  1   |  2013  |   2   |  2    |   6    |
 1-2-2013 00:01:01 |  1   |  2013  |   2   |  3    |   9    |
 1-2-2013 00:02:01 |  1   |  2013  |   2   |  4    |   12   |
 1-3-2013 00:00:01 |  1   |  2013  |   3   |  5    |   15   |
 1-3-2013 00:01:01 |  1   |  2013  |   3   |  6    |   18   |
 1-3-2013 00:02:01 |  1   |  2013  |   3   |  7    |   21   |
Now what I'm trying to get is this result
   Year    Month   Value    Cost
|--------|-------|-------|--------|
|  2013  |   1   |  1    |   3    |
|  2013  |   2   |  4    |   12   |
|  2013  |   3   |  7    |   21   |
As you can see I'm trying to GROUP BY the [Month] and the [Year] and to get the last [Value] for every [Month].
Now as you can understand from the result I do not try to get the MAX() value from the [Value] column but the last value for every [Month] and that is my issue..
Thanks in advance
PS
I was able to GROUP BY the [Year] and the [Month] but as I understand that when I adding the [Value] column the GROUP BY is not effecting the result, as the SQL need more spcification on the value you what the SQL to get..
 
     
     
     
    