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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:44:46+00:00 2026-06-09T12:44:46+00:00

Suppose we have some data that looks like so R_Id Nm Base Dest Proj

  • 0

Suppose we have some data that looks like so

R_Id    Nm      Base       Dest    Proj      Cust_id  201203   201202   201201
MRBR    Bob     LONDON     UK      Project1  1        0        0        0
MRBU    Frank   LONDON     London  Project2  2        11.68    0        248.93
MRBU    Frank   LONDON     UK      Project3  1        7.4      4.8      0
MRGB    Barry   GUILDFORD  Hull    Project4  1        50.36    12.85    48.92
MRGB    Barry   GUILDFORD          Project5  1        0        177.31   0
MRGB    Barry   GUILDFORD  INTL    Project6  3        0        331.08   0

And suppose we have a lot more columns than above, but we’ve limited to a few for now.

I want to be able to use a where statment to only show rows where the row needs further investigation. This is done by saying “Where are there more than two large numbers next to each other in a row?” So I need to count the number of rows where the number is large.

The output should look like such, where I’ve explained what filtering I’m doing.

R_Id    Nm      Base       Dest    Proj      Cust_id  201203   201202   201201
MRBR    Bob     LONDON     UK      Project1  1        "Numbers not Large"
MRBU    Frank   LONDON     London  Project2  2        11.68    248.93   0   
MRBU    Frank   LONDON     UK      Project3  1        "Numbers not Large"
MRGB    Barry   GUILDFORD  Hull    Project4  1        50.36    12.85    48.92
MRGB    Barry   GUILDFORD          Project5  1        "Too few adjacent numbers"
MRGB    Barry   GUILDFORD  INTL    Project6  3        "Too few adjacent numbers"

It’s the case where there are too few adjacent numbers I’m trying to filter for. I need to count the numer of adjacent (or every other!) numbers in those specific columns.

I’ve looked at this question: Multiple Column Conditional Count SQL, but I don’t think I can use Count(*) as I get this error: You tried to execute a query thaty does not include the speicified expression ‘AT_RISK?’ as part of aggregate function. At risk is a column that just stores Yes/No and lives to the left of R_Id (not included above for brevity)

Can anyone help or at least point me in the right direction please? I’d really appreciate it. I’ve read the question above, and I’ve looked at how to use count in general, but this is really stumping me.

  • 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-09T12:44:47+00:00Added an answer on June 9, 2026 at 12:44 pm

    Well I can think of a somewhat ugly solution to this question, but it involves the use of a custom VBA function.

    Concatenate and Test String

    Your SQL statement should be something like:

    SELECT * FROM tblName 
    WHERE IsSeqHigh([201203] & ";" & [201202] & ";" & ..., 1000);
    

    And then, in a VBA module we define:

    Public Function IsSeqHigh(seq As String, thres As Double) As Boolean
        IsSeqHigh = False
    
        Dim valStrs() As String
        valStrs = Split(seq, ";")
    
        For n = 1 To UBound(valStrs) - 1
            If (valStrs(n) >= thres) And (valStrs(n + 1) >= thres) Then
                IsSeqHigh = True
                Exit For
            End If
        Next n
    End Function
    

    Another approach

    Alternatively, if your schema is fixed and unlikely to change – and you have a primary key value, you can write a VBA function which takes the primary key value and scans the columns for the specific condition you are looking for.

    In short, there is no good SQL-only solution that I can think of.

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

Sidebar

Related Questions

Suppose I have a data frame, df, that looks like: f t1 t2 t3
I have some C# code that looks something like this System.Data.DataRow row; var table
Suppose I have a class that processes some data: class SomeClass { public: void
Suppose you have some complex JSON like: {A : valA, B : { C
Lets suppose that I have some pages some.web/articles/details/5 some.web/users/info/bob some.web/foo/bar/7 that can call a
So lets suppose we have an action in a controller that looks a bit
My application I have an application design that looks like this: web application layer
Suppose I have this database table (some sample code below) that stores the relationship
Suppose that, I have an android app that launches browser with some url supplied
I have a url that looks like this: http://localhost/store/mens/category/t-shirts/item/a-t-shirt I have a class called

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.