i got a table like this
TABLE:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
1234 | ab | 8 | 2006-1-08
2345 | sd | 1 | 2007-1-08
2345 | sd | 5 | 2005-1-06
i need to get the latest date (lastcalled) then the following fields that will return an output like this: it will extract the latest lastcalled date.
OUTPUT:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
2345 | sd | 1 | 2007-1-08
what ive done so far is this:
select phonenum, crc, attempts, max(lastcalled) as lastcalled
from table
group by phonenum,crc, attempts
that query returned a value like this:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
1234 | ab | 8 | 2006-1-08
2345 | sd | 1 | 2007-1-08
2345 | sd | 5 | 2005-1-06
it didnt remove the previous lastcalled.
i need only the latest date and the column corresponds to the latest lastcalled column,
can someone help me thanks
TABLE:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
1234 | ab | 8 | 2006-1-08
2345 | sd | 1 | 2007-1-08
2345 | sd | 5 | 2005-1-06
i need to get the latest date (lastcalled) then the following fields that will return an output like this: it will extract the latest lastcalled date.
OUTPUT:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
2345 | sd | 1 | 2007-1-08
what ive done so far is this:
select phonenum, crc, attempts, max(lastcalled) as lastcalled
from table
group by phonenum,crc, attempts
that query returned a value like this:
phonenum | crc | attempts | lastcalled
1234 | sd | 5 | 2007-1-08
1234 | ab | 8 | 2006-1-08
2345 | sd | 1 | 2007-1-08
2345 | sd | 5 | 2005-1-06
it didnt remove the previous lastcalled.
i need only the latest date and the column corresponds to the latest lastcalled column,
can someone help me thanks
Comment