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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:19:09+00:00 2026-06-06T11:19:09+00:00

I need a little help getting this script doing what I want it to.

  • 0

I need a little help getting this script doing what I want it to.

SELECT KM.initials, 
       TPL.debprice, 
       TMP.pricegroup, 
       TMP.date 
FROM   klientmedarbejder KM 
       INNER JOIN timeprismedarbejderprisgruppe TMP 
               ON KM.employeeno = TMP.employeeno 
       INNER JOIN timeprisprisgruppelinie TPL 
               ON TMP.pricegroup = TPL.pricegroup 
GROUP  BY KM.initials, 
          TMP.date, 
          TPL.debprice, 
          TMP.pricegroup, 
          TPL.date 
HAVING ( Max(TMP.dato) = TPL.date ) 

What I need is the debPrice with the latest (max) date. An employee goes through his career, once in a while his price gets upgraded. Price gets selected from a set list of prices.

  1. KlientMedarbejder is the employee table.
  2. TimeprisMedarbejderPrisgruppe is the list of date his record get upgrade to the new price.
  3. TimeprisPrisgruppeLinie is the list of prices you can have.

I have the solution down to 2 options per employee. Hence:

emp A - 300 - 9 - 1900-01-01  
emp A - 500 - 4 - 2012-01-01  
emp B - 400 - 6 - 1900-01-01  
emp B - 800 - 8 - 2012-04-01  

Hence, first record is the default from whenever he joined the company. In 2012 he was finally good enough for a better price tag. Now I need the answer with the latest date on the upgrade list for each employee. Hence emp A should give me 500 and emp B should give me 800. Now not all employees may have had the 01-01 or 04-01 price update. Some employees have had up to 8 upgrades over time, I only care for the latest.

Client I’m pulling this data from is running an SQL Server 2000.

  • 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-06T11:19:10+00:00Added an answer on June 6, 2026 at 11:19 am

    The typical solution for SQL Server 2000 is to isolate the employeeno and their max date (this is much easier in 2005+). Pseudo-code:

    SELECT d.columns, etc. FROM
    (
      SELECT employeeno, [date] = MAX([date])
      FROM dbo.tablewithdates
      GROUP BY employeeno
    ) AS grouped_emp
    INNER JOIN dbo.tablewithdates AS d
    ON d.employeeno = grouped_emp.employeeno
    AND d.[date] = grouped_emp.[date]
    INNER JOIN ...
    

    The danger is if employeeno + date is not unique, you could get multiple rows, so you need to determine how to deal with ties.

    I would write it for your schema but I can’t reverse engineer your query to figure out which table is which. Start simple and work up.

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

Sidebar

Related Questions

I need a little help getting this jQuery plugin to work correctly for me.
I need a little help getting a tar file to download from a website.
Need a little help with my jquery here I want all my button with
I need a little help with my .htaccess before I deploy it! I want
I need a little help with this.. I need to take only the numbers
I need a little help with ClientDatasets in Delphi. What I want to achieve
guess its getting late, and Im a beginner, just need a little help.. Im
Guys i need some help here , im getting this error here at the
I am just getting started with Code Contracts, and need a little help in
Need a little help getting the following rule working: RewriteCond %{HTTP_HOST} ^asset.*.domainone\.com [NC,AND] RewriteCond

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.