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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:22:29+00:00 2026-06-12T08:22:29+00:00

Maybe I’m looking at this problem all wrong, but here goes. We have a

  • 0

Maybe I’m looking at this problem all wrong, but here goes.

We have a database that is the backend for some CRM software we use in the office. The boss wants a simple query to extract birthdays from clients and their spouses.

The table structure is as follows:

Client Details Table:
Client Name, Client Birthday, Spouse Name, Spouse Birthday, <etc>

I have a simple query with a case select that will determine if the client’s birthday or the spouse’s birthday is any time in the next month.

Query is compacted as follows:

SELECT a.*
FROM
  (SELECT
     (CASE    WHEN <birthday calculation>
              ELSE NULL 
      END) as WhoHasBDay,
      ClientName,
      SpouseName
   FROM
     ClientDetailsTable) as a
WHERE
   a.WhoHasBDay IS NOT NULL

This will return any entries where the client or the spouse has a birthday in the next X days.

However, if a client AND their spouse has a birthday in the next X days, I would like the query to return the result once for each.

IE, here is the following data

CLIENT X: Birthday in 5 days
CLIENT Y: Spouse's Birthday in 8 days
CLIENT Z: Birthday in 3 days, Spouse's Birthday in 9 days.

The result set I want is

CLIENT X BDAY T+5
CLIENT Y SPOUSE BDAY T+8
CLIENT Z BDAY T+3
CLIENT Z SPOUSE BDAY T+9

Perhaps I’m approaching this problem the wrong way, in which case suggestion on a better method of attacking it would be appreciated. Otherwise if there’s a solution to this, please let me know.

  • 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-12T08:22:30+00:00Added an answer on June 12, 2026 at 8:22 am

    I’d tackle this as a UNION of two separate queries: one for clients and one for their spouses.

    SELECT ClientName, NULL AS SpouseName, Birthday
        FROM ClientDetailsTable
        WHERE <birthday calculation is true>
    UNION ALL
    SELECT ClientName, SpouseName, SpouseBirthday
        FROM ClientDetailsTable
        WHERE <spouse birthday calculation is true>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is very basic, but I am all confused. I have a simple
Maybe a silly question but here goes anyway. Example: Let's say I have one
Maybe title is confusing you, but the problem is concretely here : I have
Maybe I'm misunderstanding how inheritance works here, but here's my problem: I have a
Maybe it's wrong but I always use this query for my app: cme_only =
Maybe I am being stupid, but this isn't making sense to me... I have
Maybe I misunderstood this but from what I read I may have several problems
Maybe I'm just thinking about this too hard, but I'm having a problem figuring
Maybe world peace would be easier, but I have a problem with the widths
Maybe this is a dumb question, but I have the following behavior in Visual

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.