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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:28:20+00:00 2026-06-10T22:28:20+00:00

I am using the following script to try and count the number of new

  • 0

I am using the following script to try and count the number of new comments and new discussions created in a group on our system between the last time you visited the group and now. I have written the following but cant get it to work:

SELECT TOP(6) a.GroupID , a. GroupName, sbuser.sf_NewGroupActivity( a.GroupID ,b.LastVisited) AS NumberUpdates
FROM Groups a
INNER JOIN GroupMembers b ON b .GroupID = a.GroupID
WHERE b. MemberID = 102
GROUP BY a.GroupID , a.GroupName, b.LastVisited
ORDER BY NumberUpdates ASC

and the sf script is as follows:

RETURNS INT
AS
    BEGIN
    DECLARE @OUTSTR INT
    DECLARE @OUT1 INT
    DECLARE @OUT2 INT
    SET @OUT1 = (SELECT CAST(COUNT(GroupDiscussionsID) AS INT) FROM GroupDiscussions
            WHERE MemberID = @GroupID AND CreateDate BETWEEN @LastVisited AND GetDate())
    SET @OUT2 = (SELECT CAST(COUNT(GroupCommentID) AS INT) FROM GroupComments
            WHERE MemberID = @GroupID AND CreateDate BETWEEN @LastVisited AND GetDate())
    SET @OUTSTR = @OUT1 + @OUT2
    RETURN @OUTSTR
    END

I am at a loss as to how to get this to list the top 6 groups that have updates order by number of updates. Any ideas, suggestions, or solutions would be greatly appreciated. Many thanks

neojakey

  • 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-10T22:28:21+00:00Added an answer on June 10, 2026 at 10:28 pm

    I believe your problem is in the WHERE clause of your function:

     WHERE MemberID = @GroupID AND . . .
    

    Presumablyl, this should be comparing either MemberIDs or GroupIds, but not to each other.

    However, I would strongly suggest that you remove the function call and create a single query for the counts. This allows the SQL to create a better execution plan. If you want to do this, and don’t know how, post another question.

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

Sidebar

Related Questions

I am using the following script <script> function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new
I'm using the following script to request new content to a file called index.html:
I created a lightbox using the following script: <script type=text/javascript> $(document).ready(function(){ $(.BtnAction).click(function(){ var objPopup
I am using the following script to export a list of our products to
I am using the following script from nettuts: // Our custom error handler function
I have created a user in SQL-2008 R2 using the following script Use [CamelotShiftManagement]
I've tried to change filenames using following script: find dir/ -type f -exec mv
I'm using the following script in my website in order to create pagination next-previous
I'm using the following script to force a specific page - when loaded for
I am currently using the following script to set this value as a String:

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.