I have two tables:
PARENT (EMAIL,NAME,ETC)
CHILD (EMAIL,DOC_DOC_ID,DOWNLOAD_DATE,RANK)
I need to generate a query that will update the CHILD.RANK Field, with a numerical sorting that will rank each distinct DOC_ID by the date that it was downloaded (1 = latest doc download)
SELECT
P.EMAIL,
C.DOC_ID,
MAX(C.DOWNLOAD_DATE)
FROM
PARENT P,
CHILD C
WHERE
P.EMAIL = C.EMAIL
Please dont laugh at what i have come up with so far!… i think my brain is fried!
If you are using Rank_ID for more than display (which should be left to the queries) your design may have issues.
Have you considered what would happen if you checked out DOC_ID = 1 today and then ran an update to give it rank one and then the same thing happened tomorrow and you now have two records for DOC_ID = 1 with a RANK of 1?
You could use something like this to just display the records in the correct order. Query 1 will just display the records in order. Query 2 will add a Rank value (requires the first query).