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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:17:57+00:00 2026-06-16T15:17:57+00:00

I want to return whether or not we offer service in a particular location.

  • 0

I want to return whether or not we offer service in a particular location. The heirarchy is Zip Code > State > CountryWide

So if you enter a TX zip-code, it will first see if there’s a zip entry. If not, it will check for a TX entry. If still no hits, it will check countrywide policies.

To achieve this, I have a Calc field that indicates the level of specificty. Zip Codes are level 3, States = 2, CW =1. So a simple MAX will let me know what level of data I’m dealing with. An example of my query for this is:

SELECT Service_Availability.Service_Product, MAX(Service_Availability.Specificity) AS Spec
FROM Service_Availability
WHERE Service_Availability.State = "TX" OR Service_Availability.State = "CW"
GROUP BY Service_Product;

Now here is where my issue comes in.

I want to know if service is available at the highest level of specificity provided. However, I don’t have the correct approach…

SELECT Service_Availability.Service_Product, MAX(Service_Availability.Specificity) AS Spec
FROM Service_Availability
WHERE (Service_Availability.State = "TX" OR Service_Availability.State = "CW") 
AND Service_Availability.Available = TRUE
GROUP BY Service_Product;

This returns the highest level of specificity where Service is available, not if the service is available at the highest level of specificity.

To say another way, suppose the zip is 68123 (Omaha, Nebraska).

My db shows that we do provide service in Nebraska, but for whatever reason, we specifically cannot provide service in Omaha (68123). I want the db to see I have zip level data, and use that to determine availability (FALSE).

I understand why my code is the wrong approach, but I’m not sure which direction to come at it from. Help is appreciated!

  • 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-16T15:17:58+00:00Added an answer on June 16, 2026 at 3:17 pm

    You’ll need to INNER JOIN your initial query (almost) as a subquery to get this to work:

    SELECT Service_Availability.Service_Product, Service_Availability.Specificity 
    FROM Service_Availability 
    INNER JOIN (
        SELECT Service_Availability.Service_Product, MAX(Service_Availability.Specificity) AS Spec
        FROM Service_Availability
        WHERE (Service_Availability.State = "TX" OR Service_Availability.State = "CW")
        GROUP BY Service_Availability.Service_Product ) max_spec
      ON Service_Availability.Service_Product = max_spec.Service_Product
      AND Service_Availability.Specificity = max_spec.Spec
    WHERE Service_Availability.Available = TRUE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to return nothing when if condition is not met, for instance (if
I want to detect whether or not a subrange of an array contains the
I want to make an HTML element visible based on whether or not another
I am using the jQuery .filter() function to check whether or not a particular
I have a function whose return type is Table This code does not work.
I want to use Watir to tell whether or not an element is hidden
I want to add a function to return whether the first letter is a
I want to determine whether or not a file is located on a local
I want to change my layout based on whether or not the current user
I want to return a specific message on error of an ajax request. [WebMethod]

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.