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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:54:30+00:00 2026-05-27T21:54:30+00:00

I am trying to create a query in SQL Server that will search for

  • 0

I am trying to create a query in SQL Server that will search for all combinations of numbers in a table.

COMBINATION TABLE

CombID     Comb_Num1     Comb_NumTwo     Comb_NumThree
   1           1              2                3
   2           2              10               15
   3           5              20               60
   4           10             22               50
   5           22             33               46           

The numbers range from 1-60, and the same number is not repeated within a combination. Order does not matter.

ENTRY TABLE

EntryID     NumberOne     NumberTwo     NumberThree     NumberFour     NumberFive
   1            10           22             33              46              50
   2            2            10             15              22              40
   3            24           33             40              45              50
   4            5            10             22              40              60
   5            2            6              10              22              40
   6            2            10             22              50              60
   7            10           22             33              46              50

The numbers range from 1-60, and the same number is not repeated within an entry. Order does not matter.

Results

  • Searching for combination 1 would produce no results
  • Searching for combination 2 would return EntryID 2
  • Searching for combination 3 would produce no results
  • Searching for combination 4 would return EntryID 1, 6, 7
  • Searching for combination 5 would return EntryID 1, 7

The query should also show for each record in the Combination table how many times it has appeared in the Entry table. It should exclude the combinations that don’t appear in the Entry table.

  • 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-27T21:54:31+00:00Added an answer on May 27, 2026 at 9:54 pm

    Try:

    select distinct e.EntryID
    from entry e, combination c
    where c.Comb_Num1 in (e.NumberOne, e.NumberTwo, e.NumberThree, e.NumberFour, e.NumberFive)
    and   c.Comb_Num2 in (e.NumberOne, e.NumberTwo, e.NumberThree, e.NumberFour, e.NumberFive)
    and   c.Comb_Num3 in (e.NumberOne, e.NumberTwo, e.NumberThree, e.NumberFour, e.NumberFive)
    and   c.CombID = @CombID
    

    – to return matching entries for a specific @CombID

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

Sidebar

Related Questions

I'm trying to create a query on SQL server 2005 that will check if
I'm trying to create an SQL query in PHP to update a table. Is
I am trying to create a report in SSRS2000 that will query an ORACLE
I am trying to create a query that will shift the results on each
I'm trying to create a simple database table using the PHP MySQL query Create
I am trying to create Linq Expression that I can use to query child
I am using SQL Server 2005. I want to create a stored procedure that
I am trying to make one stored procedure only in SQL Server that lets
I'm writing an application that will have a SQL Server backend that will store
Using SQL Server, I'm trying to query a kind of averaged count from a

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.