Hi
I have a table like so:
id | file_id | file_repository_id | version_number | filename | package_id
7 | 5 | 7 | 1 | file1 | 11
8 | 6 | 8 | 1 | file2 | 11
9 | 5 | 9 | 2 | file1.1 | 11
10 | 5 | 10 | 3 | file1.2 | 11
I would like to get out the filename or each highest versioned file, ie id's 10 and 8 with the correct filename ie:
7,5,7,file1
and
10,5,10,3 file1.2
but my SQL:
SELECT filename AS filename,
file_id AS file_id,
file_repository_id AS file_repository_id,
MAX(version_number) AS version_number
FROM version
WHERE package_id = 11
GROUP by file_id
works well but fails to give the correct filename on the highest version_number, it gives the first filename of that file.
Anybody even understand what I wrote!
Please help.....
Thanks
Richard
I have a table like so:
id | file_id | file_repository_id | version_number | filename | package_id
7 | 5 | 7 | 1 | file1 | 11
8 | 6 | 8 | 1 | file2 | 11
9 | 5 | 9 | 2 | file1.1 | 11
10 | 5 | 10 | 3 | file1.2 | 11
I would like to get out the filename or each highest versioned file, ie id's 10 and 8 with the correct filename ie:
7,5,7,file1
and
10,5,10,3 file1.2
but my SQL:
SELECT filename AS filename,
file_id AS file_id,
file_repository_id AS file_repository_id,
MAX(version_number) AS version_number
FROM version
WHERE package_id = 11
GROUP by file_id
works well but fails to give the correct filename on the highest version_number, it gives the first filename of that file.
Anybody even understand what I wrote!
Please help.....
Thanks
Richard