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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:10:10+00:00 2026-06-01T18:10:10+00:00

I have a table with 3 rows: AccountNum, InvoiceAcc and Blocked. Most rows my

  • 0

I have a table with 3 rows: AccountNum, InvoiceAcc and Blocked. Most rows my table have an InvoiceAcc but not all. AccountNum is the unique identifier and its possible for a number of AccountNum’s to have the same InvoiceAcc. Blocked is an int value varying from 0, 1 and 2.

The InvoiceAcc is based off of an AccountNum so think of it as a Parent Office which then has proceeding Child Offices.

For example, a parent office like so:

AccountNum - 1, InvoiceAcc - null, Blocked - 2 might have a child offices like so:

AccountNum - 1-1, InvoiceAcc - 1, Blocked - 0

AccountNum - 1-2, InvoiceAcc - 1, Blocked - 1

What I’d like to do is check the InvoiceAcc of a row and its subsequent AccountNum blocked value. So in my example above, If I did a query like so:

SELECT BLOCKED FROM CustTable WHERE AccountNum = '1-1' 

It would return 0 as that is the blocked value. What I’d like it to do is return 2 as that has the higher value and its the parent account. Also, if the parent acc has a blocked value of 1 and the child account which I’m querying has an blocked value of 2, then it should return 2. Im assuming a subselect would be needed here?

It should return the highest blocked value based on either itself or its parents account, if it has a parent account

  • 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-01T18:10:11+00:00Added an answer on June 1, 2026 at 6:10 pm

    You can add a write your query like this as only as you only have one level (e.g. parent -> child)

    SELECT CASE 
      WHEN child.blocked > COALESCE(parent.blocked,0)
      THEN child.blocked 
      ELSE parent.blocked 
    END as blocked
    FROM CustTable child 
    LEFT JOIN CustTable parent ON child.InvoiceAcc = parent.AccountNum
    WHERE child.AccountNum = '1-1' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table, with rows which all have a cell of a div
I have table rows that move up and down, but my problem is that
how remove html table rows after 2nd row? if in table have 5 row,
I have table of 5000+ rows and 8+ columns like, Station Lat Long Date
I have table with few rows, after use hover mouse over row I want
I have a table with rows of alternating colors, e.g.: <table> <tr class=even><td></td><td></td></tr> <tr
On my pages I have a table with rows that typically look like this:
I have a table with multiple rows in each row is a select list
I have a table with many rows of data, and I want to show
I have a large table (~1M rows now, soon ~10M) that has two ranked

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.