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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:00:45+00:00 2026-06-17T11:00:45+00:00

I usually use COUNT within a subquery to grab the desired number, but in

  • 0

I usually use COUNT within a subquery to grab the desired number, but in this case I need a little help as the query contains too many arguments.

SELECT a.[QueueID]
  ,a.[CouponID]
  ,a.[ListingID]
  ,a.[User_ID]
  ,b.[CouponID]
  ,b.[ListingID]
  ,b.[CouponActive] 
  ,b.[CouponExpire] 
  ,b.[IsDeleted]
  ,c.[ListingID]
  ,c.[TypeID]
  ,c.[LevelID]
  ,@passedUserID as User_ID

FROM CouponQueue a
JOIN Coupon b
    on a.CouponID = b.CouponID
JOIN Listing c
    on b.ListingID = c.ListingID

WHERE (a.[User_ID] = @passedUserID)
AND (b.[CouponActive] = 1)
AND (b.[IsDeleted] = 0)
AND (b.[CouponExpire] > DATEADD(dd, -1, GETDATE()) OR b.[CouponExpire] IS NULL)

So lets say this query returns a result of 7 rows. All I need is this number for my VIEW. So I want to limit the ultimate result to a single row so that in the end I get:

[TotalCount] <-- Field name
[7] <-- Result

But not 7 rows of data.. I just need the count from the above query. Still plugging away and trying to learn. I looked at a few other examples but I haven’t found one with all the conditions… which is what’s messing me up. Please help!

Thank you so much!

  • 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-17T11:00:47+00:00Added an answer on June 17, 2026 at 11:00 am

    Would this work for you?

    select count(*) as TotalCOunt from (
    SELECT a.[QueueID] /* 
      ,a.[CouponID]
      ,a.[ListingID]
      ,a.[User_ID]
      ,b.[CouponID]
      ,b.[ListingID]
      ,b.[CouponActive] 
      ,b.[CouponExpire] 
      ,b.[IsDeleted]
      ,c.[ListingID]
      ,c.[TypeID]
      ,c.[LevelID]
      ,@passedUserID as User_ID */
    
    FROM CouponQueue a
    JOIN Coupon b
        on a.CouponID = b.CouponID
    JOIN Listing c
        on b.ListingID = c.ListingID
    
    WHERE (a.[User_ID] = @passedUserID)
    AND (b.[CouponActive] = 1)
    AND (b.[IsDeleted] = 0)
    AND (b.[CouponExpire] > DATEADD(dd, -1, GETDATE()) OR b.[CouponExpire] IS NULL)
    ) t
    

    You can remove the columns for the count. They are not actually necessary.

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

Sidebar

Related Questions

I usually use sql parameters with queries, but in this case I need to
To get the total number of records, I usually use this query: $total= mysql_num_rows(mysql_query(SELECT
I usually use a boolean 'firstTime' like this: in C++: bool firsTime = true;
I usually use Visual Studio Team System 2008 Source Control Explorer with TFS, but
I usually use this line to import file from out of the current folder
I usually use like this $ find -name testname.c ./dir1/dir2/testname.c $ vi ./dir1/dir2/testname.c it's
Platform: JCreator I usually use for loops that count from the back because theoretically
When i use vector to store some data, I usually access to this data
I've been experimenting with C a little bit. I usually use PHP and javascript.
I usually use the following pipeline to grep for a particular search string and

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.