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

  • Home
  • SEARCH
  • 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 8893127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:10:12+00:00 2026-06-14T23:10:12+00:00

There is a table called client_application with data something like this; Id user_id name

  • 0

There is a table called client_application with data something like this;

Id   user_id   name      creationDate
---------------------------------------
1    5         name1     date
2    4         name2     date
3    98        name3     date

And also a table called application_status which holds the status feed of application(application_id is foreign key);

Id   aplication_id   status            other_columns      creationDate
----------------------------------------------------------------------
1    1       APPLICATION_SUMITTED      data               date
2    2       APPLICATION_SUMITTED      data               date
3    1       APPLICATION_RECEVIED      data               date
4    1       BANK_APPROVED             data               date
5    3       APPLICATION_SUMITTED      data               date
6    2       APPLICATION_RECEVIED      data               date

I want to query the application by their status. For example get the newest submitted applications? Or get the applications which the bank approved.

How can I implement such an SQL query?

I have tried thi;

SELECT *
FROM (SELECT * FROM application_status ORDER BY creationDate DESC) t1
LEFT JOIN client_application on client_application.id = t1.application_id
GROUP BY t1.application_id;

Which is fine, I can get the applications with their latest status but when I try to put a where clause in it;

SELECT *
FROM (SELECT * FROM application_status ORDER BY creationDate DESC) t1
LEFT JOIN client_application on client_application.id = t1.application_id
where t1.status = 'APPLICATION_SUBMITTED'
GROUP BY t1.application_id;

It returns all application_status has APPLICATION_SUBMITTED status column..
It returns application_id 1 item ( check the table above) but as you can see, application with the id number 1 has APPLICATION_RECEIVED status as latest status item.. So I would not expect this one in result set.

Maybe my approach is totally wrong. I’m open for any solution.

Thanks.

  • 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-14T23:10:13+00:00Added an answer on June 14, 2026 at 11:10 pm

    My advice is to improve the design of your database by creating a new table ‘Status’ for example :

    Id   Label
    1    APPLICATION_SUBMITTED
    2    APPLICATION_RECEIVED
    3    BANK_APPROVED 
    

    You have to give the labels a logical order, and you refer to this table in your status or main table.

    It will be easier to retrieve the status of an application ( where Status.Id < 3 to select all non-approved applications, or where Status.Id > 1 to select all application that are at least received ).

    It is also better for maintenance purpose. This kind of logic applies in a lot of cases, and you should consider to spend a bit more time to design your data models, so you won’t spend more time resolving this kind of issue your are facing now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to do this : There is a table called table1 it has
i need to do this : There is a table called table1 it has
I'm looking through my organization's database, and there is a table called dbo.Account_Alerts, and
I have a table TIME_TABLE on Oracle 10.6. There is a field called Start_Date
in an sql table there's an id, first name and last name field. i'd
I am creating a model object like this: $object1 = new Object1(); There is
Let's say my SQL database contains a table called 'Customer'. This Customer has an
I've a table called data with columns ip, report_date, group, value . The primary
I have a main table called M1 which consists of Ids of three individual
Say I have a database called Poll and have these two table structures. poll

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.