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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:42:01+00:00 2026-05-31T04:42:01+00:00

Posting this again as I’ve made some updates. I’m trying to group a set

  • 0

Posting this again as I’ve made some updates.

I’m trying to group a set of values, but I only want to display the values if there was a change.

Imagine that the value is fluctuating, ranging from 1, to 4, to 3, to 1, to 1 and to 1 again.

Some example data

value | date_loaded | 
  1   |  2012-03-07 |
  1   |  2012-03-06 |
  1   |  2012-03-05 |
  3   |  2012-03-04 |
  4   |  2012-03-03 |
  1   |  2012-03-02 |

I want to display each of the values in order of which they fluctuated, but group them together. So you would only see in order, 1, 4, 3, 1, rather then the three 1’s most recently.

So I would like to display the latest value, with it’s earliest date, e.g.

value | date_loaded | 
  1   |  2012-03-05 |
  3   |  2012-03-04 |
  4   |  2012-03-03 |
  1   |  2012-03-02 |

What is the best way to go about this? Would it be possible to do an if statement? If value 1 is different to value 2, +1 to “change” ? Therefore I’d be able to group the values by “change1”, “change2” etc.?

  • 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-31T04:42:02+00:00Added an answer on May 31, 2026 at 4:42 am

    How about:

    ;WITH data AS
    (
    SELECT 1 as [value],'2012-03-07' as date
    UNION ALL SELECT 1,'2012-03-06'
    UNION ALL SELECT 1,'2012-03-05'
    UNION ALL SELECT 3,'2012-03-04'
    UNION ALL SELECT 4,'2012-03-03'
    UNION ALL SELECT 1,'2012-03-02'
    )
    ,data2 AS
    (
    SELECT 
    [Value]
    ,date
    ,row_number() OVER (ORDER BY (SELECT NULL)) as row1
    FROM data
    )
    ,data3 AS
    (
    SELECT * 
    , row1 - row_number() OVER (ORDER BY [Value]) as row2
    from data2
    )
    SELECT 
    MIN([Value]) AS [Value]
    ,MIN(Date) as Date
    FROM data3
    GROUP BY [Value] - row2
    ORDER BY MIN(row1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried posting this question earlier but was unsuccessful so I'm trying again I
(I've tried posting this on YUI message group but without any luck) Can anyone
I'm posting this question again but this time I'm including the full code. It's
Note: I am cross-posting this from App Engine group because I got no answers
First of all, I would like to apologize for posting this again. I am
Sorry for posting this question again. I rephrased my question a little bit. I
(I posted this before anonymously, but then couldn't use the same computer again, so
I am posting this question again because I didn't explain clear enough. Here are
I did check those posts about Infinite gallery before posting this question but it
Apologies for not posting any code for this but all my efforts seem to

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.