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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:32:49+00:00 2026-06-15T18:32:49+00:00

I have a table that has time scaled values and I need to be

  • 0

I have a table that has time scaled values and I need to be able to scale the values. I am trying to make this as simple as possible however speed of execution is a big player for me.

Let me give you an example of the tblTSS_DataCollection:

SELECT TOP 5
   [DataPointID]
  ,[DatapointDate]
  ,dc.[DataPointValue] 
FROM [tblTSS_DataCollection] dc
Where DatapointID = 1093

This here would return a very simple table:

DataPointID DatapointDate            DataPointValue
1093        2012-07-29 00:00:01.000  0.01869818
1093        2012-07-29 00:01:01.000  0.01882841
1093        2012-07-29 00:02:01.000  0.01895865
1093        2012-07-29 00:03:01.000  0.01908888
1093        2012-07-29 00:04:01.000  0.01921912

Now I have another table called tblTSS_ScaleSettings which looks like this:

SELECT [ID]
      ,[DatapointID]
      ,[EffectiveDate]
      ,[ScaleType]
      ,[ScaleValue]
FROM [tblTSS_ScaleSettings]

Which will return a result something like this:

ID  DatapointID EffectiveDate            ScaleType   ScaleValue
1   1093        2012-07-29 00:03:01.000  *           10.0000

Now what I need to be able to do is something like this:

SELECT TOP 5 
       dc.[DataPointID]
      ,[DatapointDate]
      ,dc.[DataPointValue] AS [DVOld]
      ,CASE sc.ScaleType
            WHEN '*' THEN dc.[DataPointValue] * sc.ScaleValue
            WHEN '/' THEN dc.[DataPointValue] / sc.ScaleValue
            WHEN '+' THEN dc.[DataPointValue] + sc.ScaleValue
            WHEN '-' THEN dc.[DataPointValue] - sc.ScaleValue
            ELSE dc.[DataPointValue]
        END
        AS [DatapointValue]
 FROM [tblTSS_DataCollection] dc
 JOIN [tblTSS_ScaleSettings] sc
 on sc.DatapointID = dc.DatapointID
 Where dc.DatapointID = 1093

Which would return:

DataPointID DatapointDate            DVOld        DatapointValue
1093        2012-07-29 00:00:01.000  0.01869818   0.1869818
1093        2012-07-29 00:01:01.000  0.01882841   0.1882841
1093        2012-07-29 00:02:01.000  0.01895865   0.1895865
1093        2012-07-29 00:03:01.000  0.01908888   0.1908888
1093        2012-07-29 00:04:01.000  0.01921912   0.1921912

However, what is wrong with this is because the scaling EffectiveDate in the table doesn’t start until 00:03:01 scaling should start then not on all the records. Scaling should be that scale until the next effectivedate. Sometimes we will have multiple Scales that happen and it changes at different times throughout the year. So I need the Select Query to plan for that…. This is where it gets tricky.

Which would look like this:

DataPointID DatapointDate            DVOld        DatapointValue
1093        2012-07-29 00:00:01.000  0.01869818   0.01869818
1093        2012-07-29 00:01:01.000  0.01882841   0.01882841
1093        2012-07-29 00:02:01.000  0.01895865   0.01895865
1093        2012-07-29 00:03:01.000  0.01908888   0.1908888
1093        2012-07-29 00:04:01.000  0.01921912   0.1921912

Can someone please help?

  • 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-15T18:32:50+00:00Added an answer on June 15, 2026 at 6:32 pm

    Something like this might work for you:

    SELECT TOP 5 
           dc.DataPointID
          ,DatapointDate
          ,dc.DataPointValue AS DVOld
          ,CASE sc.ScaleType
                WHEN '*' THEN dc.DataPointValue * sc.ScaleValue
                WHEN '/' THEN dc.DataPointValue / sc.ScaleValue
                WHEN '+' THEN dc.DataPointValue + sc.ScaleValue
                WHEN '-' THEN dc.DataPointValue - sc.ScaleValue
                ELSE dc.DataPointValue
            END
            AS DatapointValue
     FROM tblTSS_DataCollection dc
     LEFT JOIN tblTSS_ScaleSettings sc
     ON sc.DatapointID = dc.DatapointID
     AND sc.EffectiveDate = (
        SELECT MAX(EffectiveDate)
        FROM tblTSS_ScaleSettings
        WHERE DatapointID = dc.DatapointID
            AND EffectiveDate <= dc.DatapointDate
     )
     WHERE dc.DatapointID = 1093
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has a date/time field and am trying to figure
I have a table that has two datetime columns (one for start time and
I have a table that has duplicate email address, I need to insert just
I have a table that has records with a structure similar to this.. ID
i have a table that has a date/time field when i display the report,
I have a datetime column in table that has time component. Is there anyway
I have a table that has 100% width. It is generated dynamically with values
If I have a table that has 50 columns, will it take less time
I have a table that has the following columns: GRVLID GRID Timein Timeout This
I have a table that has a value field. The records have values somewhat

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.