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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:35:39+00:00 2026-06-11T23:35:39+00:00

I have the following data in a SQL table Temp table variable @RndQuesnCount contains

  • 0

I have the following data in a SQL table

Temp table variable @RndQuesnCount contains this data,

Recid conceptID MinDisplayCount
1      3839     2
2      4802     3

Question table : QuesTable

 QuesCompID     Ques_ConceptDtlID
  88         4802
  89         4802
  90         4802
  91         4802
  92         4802
  93         4802

What I would like to show is the min display count for question which is in @RndQuesnCount for the concept id, so now the data should come as below

  QuesCompID    Ques_ConceptDtlID
  88         4802
  89         4802
  90         4802

because conceptid (4802) has min display count 3 in @RndQuesnCount table.

Can anyone help me to solve this problem ?

  • 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-11T23:35:41+00:00Added an answer on June 11, 2026 at 11:35 pm

    Simple use of ROW_NUMBER() and a join gets the results, I think. Data setup:

    declare @RndQuesnCount table (recid int,conceptid int,mindisplaycount int)
    insert into @RndQuesnCount(Recid,conceptID,MinDisplayCount) values
    (1,      3839,     2),
    (2,      4802,     3)
    
    declare @QuesTable table (QuesCompID int,Ques_ConceptDtlID int)
    insert into @QuesTable(QuesCompID,Ques_ConceptDtlID) values
    (88,         4802),
    (89,         4802),
    (90,         4802),
    (91,         4802),
    (92,         4802),
    (93,         4802)
    

    Query:

    select
        t.rn,
        t.QuesCompID,
        t.Ques_ConceptDtlID 
    from
        @RndQuesnCount rqc
            inner join
        (select *,ROW_NUMBER() OVER (PARTITION BY Ques_ConceptDtlID ORDER BY QuesCompID) rn from @QuesTable) t
            on
                rqc.conceptID = t.Ques_ConceptDtlID and
                rqc.MinDisplayCount >= t.rn
    

    Results:

    rn                   QuesCompID  Ques_ConceptDtlID
    -------------------- ----------- -----------------
    1                    88          4802
    2                    89          4802
    3                    90          4802
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation similar to the following question: Insert Data Into SQL Table
I have a following SQL table with data ProductList id order productname 79 1
I have table the following data structure in SQL Server: ID Date Allocation 1,
I have the following data in a SQL Server 2000 table: Dates ----------------------- 2012-05-04
I have a sql table which have the following data, Id City Country ---
I have data in sql server table like the following: Slno Revenue Data Loading
I have the following SQL script: DECLARE @temp table ( ID int IDENTITY(1, 1),
Assume we have the following data in a SQL Server table (sorted by name)
I have the following table and data in SQL Server 2005: create table LogEntries
I have following XML, and i wish to save its data in my SQL

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.