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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:56:04+00:00 2026-05-16T02:56:04+00:00

I have some data that needs to be validated, and while I have found

  • 0

I have some data that needs to be validated, and while I have found a quick formula that works in excel I would like to find some SQL that would do the same so I can use it in my database as a check now and then.

The data is simply this:

ACACIA ST (KLN) | 1073 | 1149 | FAIL! | 76
ACACIA ST (KLN) | 1073 | 1151 | FAIL! | 78
ACACIA ST (KLN) | 1150 | 1332 | FAIL! | 182
ACACIA ST (KLN) | 1151 | 1332 | FAIL! | 181
ACACIA ST (KLN) | 1606 | 2079 |  | 473
ACTIVITY ST (WRK) | 6 | 215 | WIN! | 209
ACTIVITY ST (WRK) | 215 | 227 | WIN! | 12
ACTIVITY ST (WRK) | 227 | 423 | WIN! | 196
ACTIVITY ST (WRK) | 423 | 549 | WIN! | 126
ACTIVITY ST (WRK) | 549 | 600 |  | 51
ADRIENNE CT (WMN) | 5 | 107 | WIN! | 102
ADRIENNE CT (WMN) | 107 | 122 |  | 15
AERODROME RD (LYB) | 0 | 140 | WIN! | 140
AERODROME RD (LYB) | 140 | 428 | WIN! | 288
AERODROME RD (LYB) | 428 | 716 | WIN! | 288
AERODROME RD (LYB) | 716 | 998 | WIN! | 282
AERODROME RD (LYB) | 998 | 1280 | WIN! | 282
AERODROME RD (LYB) | 1280 | 1566 | WIN! | 286
AERODROME RD (LYB) | 1566 | 1851 | WIN! | 285
AERODROME RD (LYB) | 1851 | 2136 | WIN! | 285
AERODROME RD (LYB) | 2136 | 2421 |  | 285

Well there is a lot more data then that, ~11000+ rows of it.

Now the idea is that each road segment (the first column) has a start and end chainage (second and third column) and a length (last column), the end chainage should be the start chainage of the next segment, provided the road segment name is the same (sorted by start chainage of course). You can see that because the first rows end chainage doesn’t equal the start of the next it fails.

My bad attempt at pseudocode:

If EndChainage != NextStartChainge Where RoadSegment = NextRoadSegment Error

What I need to be able to do select all the road segments which don’t follow the rule of end chainage = start chainage of next.

So the outout from the above table would be:

ACACIA ST (KLN) | 1073 | 1149 | FAIL! | 76
ACACIA ST (KLN) | 1073 | 1151 | FAIL! | 78
ACACIA ST (KLN) | 1150 | 1332 | FAIL! | 182
ACACIA ST (KLN) | 1151 | 1332 | FAIL! | 181

Hope that makes sense. I attempted it but just could seem to get it to work, and my SQL skills are a bit lacking.

EDIT: I can use both SQL Server and PostgreSQL.

  • 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-16T02:56:04+00:00Added an answer on May 16, 2026 at 2:56 am

    Assuming that there won’t be duplicate rows, the following should be a reasonably DB-agnostic solution:

    select street, startno, endno, 
    case  (select coalesce(min(s2.startno),-1) from stackchallenge s2 
           where s1.street = s2.street and 
                 s1.startno <= s2.startno and 
                 s1.endno < s2.endno)
        when -1 then ' '
        when endno then 'WIN!'
        else 'FAIL!'
    end as validated,
    length
    from stackchallenge s1 order by 1,2,3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 536k
  • Answers 536k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's a code for it. It's quite hacky but nevertheless… May 17, 2026 at 1:22 am
  • Editorial Team
    Editorial Team added an answer position: fixed MDN documentation May 17, 2026 at 1:22 am
  • Editorial Team
    Editorial Team added an answer There are two queries here. The inner query: SELECT TOKENID… May 17, 2026 at 1:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some data that's currently stored in an Excel workbook. It makes sense
I have created an Excel Sheet that does some lookups to format data that
I have some text that needs to be displayed in my app. The text
I've created some classes that will be used to provide data to stored procedures
I have some tabular data. In the last column, I have 2 divs, one
I am building a ASP.NET Mvc app. I have a Data model say User
I have a small JSF application where the user is required to enter some
I'm using the jQuery Validation plugin on my forms. I have some groups of
I have a long spreadsheet with tariff codes that I need to validate and
I'm trying to validate some POST data. One of the validations I need 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.