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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:28:20+00:00 2026-06-13T02:28:20+00:00

What I have is 2 tables. table A looks like: actID; jobnumber; actTypeID; completeDate

  • 0

What I have is 2 tables. table A looks like:

actID; jobnumber; actTypeID; completeDate
1;    2000;       3;      2012-09-04
2;    2000;       4;      2012-09-05
3;    2001;       2;      2012-09-10
4;    2001;       4;      2012-09-05
5;    2001;       5;      2012-09-05
6;    2002;       1;      2012-09-12

Table B looks like:

actTypeID;  actType;  projStatus;
1;     Pick;    Build;
2;     Bid;     Estimate;
3;     PMQC;    QC;
4;     Equipment Test;    QC;
5;     Assembly;    Build;

What I need to do is include the projStatus and actType in this:

SELECT jobnumber,
    max(completedate) completedate
FROM tableA
GROUP BY jobnumber

without increasing the number of records returned, ie get this set back:

jobnumber; actType; projStatus; completedate;
2000;  EquipmentTest; QC;       2012-09-05;
2001;  Bid;           Estimate; 2012-09-10;
2002;  Pick;          Build;    2012-09-12;

I’m on SQL server 2005 right now, soon to be 2008. I feel like I’m missing the trick to this.

  • 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-13T02:28:21+00:00Added an answer on June 13, 2026 at 2:28 am

    Try this,

    SELECT  x.[jobnumber], x.[actType], x.[projStatus], x.[completeDate]
    FROM
    (
    SELECT a.[actID], a.[jobnumber], b.[actType], b.[projStatus], a.[completeDate],
          ROW_NUMBER() OVER 
         (PARTITiON BY jobnumber ORDER BY [completeDate] DESC ) xx
    FROM table1 a
          INNER JOIN table2 b
            on a.[actTypeID]=b.[actTypeID]
    ) x
    WHERE x.xx = 1
    

    SQLFiddle Demo

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

Sidebar

Related Questions

I have two tables Department and Employee . Department table looks like this: ID
I have two tables which looks something like this Table Queue int ID; string
I have three tables: Campus Building Floor and table structure is looks like this:
I have two tables: fighters and weight_divisions . My weight_divisons table looks like this:
I have tables which looks like below. Employee table Date Employee ID Employer ID
I have two tables. One table looks like ORDER_ID | SHOPPER_NAME | DATE -------------------------------
I have two tables, songs and history. The songs table looks like: ID |
I have two tables. First table looks like this: Table: Records rid | user
I have multiple tables in my database. Let's say the table users looks like
Using sqlite3, I have a table that looks like this: +---------+-----------------+----------+-----------+--------+ | ArtId |

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.