Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8796967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:44:45+00:00 2026-06-13T23:44:45+00:00

I have two tables: PARENT (EMAIL,NAME,ETC) CHILD (EMAIL,DOC_DOC_ID,DOWNLOAD_DATE,RANK) I need to generate a query

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:44:46+00:00Added an answer on June 13, 2026 at 11:44 pm

    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).

    QUERY 1:
    SELECT
        LAST(EMAIL) AS EMAIL,
        DOC_DOC_ID,
        Max(DOWNLOAD_DATE) AS DOWNLOAD_DATE
    FROM 
        CHILD
    GROUP BY 
        DOC_DOC_ID
    ORDER BY 
        Max(DOWNLOAD_DATE) DESC;
    
    
    QUERY 2:
    SELECT 
        testing.EMAIL, 
        testing.DOC_DOC_ID, 
        testing.DOWNLOAD_DATE, 
        (select 
             count(*)
         from
             Query1
         where
             DOWNLOAD_DATE>testing.DOWNLOAD_DATE)+1 AS RANK
    FROM
        Query1 as testing
    ORDER BY
        testing.DOWNLOAD_DATE DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that represent parent/child nodes, their types, and their relationships: Table
I have two tables: parent-child 'categories': id name parent_id 1 Food NULL 2 Pizza
I have two tables a parent and a child table. The child table has
I have two tables Loan(Parent Table) and Receipt(Child table)what i want to do is
I have a table with two child tables. For each record in the parent
I have two parent tables, BusinessGroup and SocialGroup, and one child table, Members. A
I have two tables, one parent and one child table. Child will have many
I have two tables, one table A that is the parent and other table
Suppose I have two tables in a parent - child relationship. Let's call them
Assume that I have two parent tables: Company and Contact . Assume that both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.