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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:56:51+00:00 2026-05-26T01:56:51+00:00

let’s say I have the following objects: Site: idSite, name and other static data.

  • 0

let’s say I have the following objects:

Site: 

idSite,
name
and other static data. 

Test:

idTest
idSite
name
and other static data.

Site Version:

idSiteVersion,
idSite
name of version


Test Result:

ןdTestResult
idSiteVersion, 
idTest,
timeEnded

for each site, there is a list of tests that are registered for him.

now I want to know for each site version the latest testresults for them, grouped by idTest.
and also those who are not tested, with null as value.(b)

I’ve implimented a DB for this.

but I have trouble to get the query I’ve listed (b) , it takes a considerbly long time.

I’m thinking of remodeling it. any advices will help

the new one will consist of a table LATEST that will act as a cache,
so I’ll use triggers on insert to update the right row,
and will select from it.

is that right?
should I remodel this?

query:

select `tr1`.`id` AS `id`,
`dsv`.`idSite_id` AS `idSite`,
`tr1`.`idSiteVersion_id` AS `idSiteVersion`,
`tr1`.`idTest_id` AS `idTest`,
`tr1`.`result` AS `result`,
`tr1`.`timeStarted` AS `timeStarted`,
 from 
`dash`.`testresult` `tr1` 
join `dash`.`siteversion` `dsv` on `dsv`.`id` = `tr1`.`idSiteVersion_id`
join `dash`.`test` `dtest` on `dtest`.`id` = `tr1`.`idTest_id` 
where `dtest`.`ignored` = 0 and `tr1`.`timeEnd` = 
( select max(`tr2`.`timeEnd`) from `dash`.`testresult` `tr2` 
    where 
       ((`tr2`.`idTest_id` = `tr1`.`idTest_id`) and 
       (`tr2`.`idSiteVersion_id` = `tr1`.`idSiteVersion_id`) and 
       (`tr2`.`timeEnd` is not null)))
  • 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-05-26T01:56:52+00:00Added an answer on May 26, 2026 at 1:56 am

    Try it like this:

    SELECT
      tr1.id AS id,
      dsv.idSite_id AS idSite,
      tr1.idSiteVersion_id AS idSiteVersion,
      tr1.idTest_id AS idTest,
      tr1.result AS result,
      tr1.timeStarted AS timeStarted,
    FROM 
      dash.testresult AS tr1 
      NATURAL JOIN (
        SELECT idTest_id, idSiteVersion_id, MAX(timeEnd) AS timeEnd
        FROM dash.testresult
        WHERE timeEnd IS NOT NULL
        GROUP BY idTest_id, idSiteVersion_id
      ) AS tr2
      JOIN dash.siteversion AS dsv
        ON dsv.id = tr1.idSiteVersion_id
      JOIN dash.test AS dtest
        ON dtest.id = tr1.idTest_id AND dtest.ignored = 0
    

    Also, you definitely want to create an index on dash.testresult (idTest_id, idSiteVersion_id, timeEnd) if you don’t already have one.

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

Sidebar

Related Questions

Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have window.open (without name parameter), scattered in my project and I
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
let's say I have the following string: string s = A B C D
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say, I have a .NET 2 installed. Can I programmatically install version 4
Let's say I have a main folder in my website named test which contains
Let say I have the following desire, to simplify the IConvertible's to allow me
Let's say I have the following function in C#: void ProcessResults() { using (FormProgress

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.