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 7759221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:34:22+00:00 2026-06-01T13:34:22+00:00

I am very new to using SQL and I haven’t been able to find

  • 0

I am very new to using SQL and I haven’t been able to find any previous posts that seem to answer my question. I need a statement that will give me the latest approved submission for every customer in the database and all rows/columns of data associated with that submission. Each submission is assigned a unique id number and is in a column called ASMT_ID. The unique customer id number is a column called PRTPT_ID.

So, for each PRTPT_ID in the database T_FINANCIAL_ITEM, I want to find the MAX ASMT_ID for each customer and display all columns and rows of data associated with each PRTPT_ID, but only if the STTS_NAME is equal to “Approved”.

In my simple terms what I’m trying to do:

select * from T_FINANCIAL_ITEM
For each PRTPT_ID SELECT MAX ASMT_ID
WHERE STTS_NAME = 'Approved'
GROUP by PRTPT_ID

*UPDATE*
Rather than using the asmt_id, I will need to analyze two other fields in the same table FYE_DT and SUBM_TYPE.

The criteria is:

  1. The most recent FYE_DT with a stts_name ‘Approved’ (i.e. 2011 before 2010).
  2. In the most recent fye_dt, the audited subm_type
  3. In the most recent fye_dt, if their is no audited subm_type, the unaudited subm_type
  4. It will pull all rows of data associated with the submission meeting the criteria

For example:

PRTPT_ID    ASMT_ID FYE_DT                       SUBM_TYPE_NAME  
8493000000  18016   30-JUN-09 12.00.00.000000000 AM Unaudited/A-133  
8493000000  19574   30-JUN-09 12.00.00.000000000 AM Audited/A-133  
8493000000  28039   30-JUN-10 12.00.00.000000000 AM Unaudited/A-133  
8493000000  33620   30-JUN-10 12.00.00.000000000 AM Audited/A-133  
9481000000  38049   31-DEC-10 12.00.00.000000000 AM Unaudited/Non-A133  
9481000000  58020   31-DEC-09 12.00.00.000000000 AM Audited/Non-A-133  
9481000000  48139   31-DEC-11 12.00.00.000000000 AM Unaudited/Non-A-133  

Result:

PRTPT_ID    ASMT_ID FYE_DT                       SUBM_TYPE_NAME  
8493000000  33620   30-JUN-10 12.00.00.000000000 AM Audited/A-133  
9481000000  48139   31-DEC-11 12.00.00.000000000 AM Unaudited/Non-A-133  

Note: There can be multiple rows of data associated with these results. I need to have all of the rows of data.

  • 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-01T13:34:23+00:00Added an answer on June 1, 2026 at 1:34 pm

    One relatively standard approach would be to use analytic functions. If I understand your update, it sounds like you want the ORDER BY clause to be something like

    select *
      from (select t.*,
                   rank() over (partition by prtpt_id
                                          order by fye_dt desc,
                                                   (case when subm_type_name like 'Audited%'
                                                         then 2
                                                         when subm_type_name like 'Unaudited%'
                                                         then 1
                                                         else 0
                                                      end) desc) rnk
              from t_financial_item t
             where stts_name = 'Approved')
     where rnk = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to using Linq-to-SQL, that's why I'm asking this question. I've searched
Very new to using Raphael.js I'm looking at the tutorials and I am able
I am very new to SQL and am using SQLite 3 to run basket
I am very new to SQL and am using SQLite 3 to run basket
I'm very new to PHP, SQL I've worked with using Coldfusion but only with
I am very new to NTLM/LDAP and trying to authenticate using NTML running on
I am very new to nservicebus. I am using version 3.0.1, the last one
I'm very new to C#. My boss asked me to wrote some code using
Guys i am very new to jQuery. I have started using the auto complete
I'm very new to MVC, and just building my first site, using NerdDinner as

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.