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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:40:16+00:00 2026-05-27T16:40:16+00:00

I have a very simple item ownership table with these two columns: UserID, ItemID

  • 0

I have a very simple item ownership table with these two columns:

UserID, ItemID

There is an index on UserID, but not ItemID.

I have a set S of 10-40 specific ItemIDs (in my queries they are just a comma delimited list of integers).

I want to find all UserIDs that own at least X (distinct ItemIDs) of the items in S.

I am using MSSQL if it matters. Can this be done efficiently?

  • 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-27T16:40:17+00:00Added an answer on May 27, 2026 at 4:40 pm
    select UserID
    from Ownership 
    where ItemID in (1,2,3,4,5,...) --your list of ItemIDs
    group by UserID
    having count(distinct ItemID) >= 3 --the minimum # of distinct items required
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a query: (using a very simple example) SELECT ItemCategory, ItemID, Sales FROM
i have a very simple question, actually this is not the question, this is
I have created a very simple model called Discussion and one of the columns
I have a very simple cart which displays the item quantity in a text_field,
This is a very simple question. I have a Html.helper: @Html.DisplayFor(modelItem => item.Text) How
I'm trying to build a very simple pure css navigation bar, but have hit
I have a very simple script that uses Copy-Item in the Task Build section
i have very simple problem. I need to create model, that represent element of
I have very simple window where I have 2 buttons - one for cancel,

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.