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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:49:39+00:00 2026-05-23T10:49:39+00:00

Is there a query where I could match if field cmd has been sent

  • 0

Is there a query where I could match if field cmd has been sent more then 3 times with the same content in the last 15 minutes ?

I currently have this:

SELECT COUNT(*) 
FROM `log` 
WHERE gid = @gid 
AND ts_register BETWEEN DATE_SUB(NOW() , INTERVAL 15 MINUTE) AND NOW()

Which will gather me all the messages sent in the last 15 minutes by the global id.

Is there a way to take the field cmd into consideration and list if the gid has sent a repeated cmd more then 3 times within the last 15 minutes ?

for example:

gid 1 cmd testing repeatable cmd
gid 1 cmd testing repeatable cmd
gid 1 cmd testing repeatable cmd
gid 1 cmd different cmd

So it would give me the count of 3.

  • 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-23T10:49:39+00:00Added an answer on May 23, 2026 at 10:49 am

    You want to do this:

    SELECT cmd, COUNT(*) Qty
    FROM `log` 
    WHERE gid = @gid 
    AND ts_register BETWEEN DATE_SUB(NOW() , INTERVAL 15 MINUTE) AND NOW()
    GROUP BY cmd
    

    Given your data, that would return:

    Cmd                                  Qty
    ---                                  ---
    gid 1 cmd testing repeatable cmd     3
    gid 1 cmd different cmd              1
    

    Update

    Using @Gidon’s suggestion (Upvoted you, man!), you can add a HAVING clause to display only the ones with more than 3:

    SELECT cmd, COUNT(*) Qty
    FROM `log` 
    WHERE gid = @gid 
    AND ts_register BETWEEN DATE_SUB(NOW() , INTERVAL 15 MINUTE) AND NOW()
    GROUP BY cmd
    HAVING COUNT(*) > 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: For the inner queries, there could be more than one match per inner
Is there a SQL command that could be used in a query, stored procedure,
Is there any query which can return me the number of revisions made to
Is there a single query (subqueries in it are allowed) where I can copy
I have a method that takes an IQueryable. Is there a LINQ query that
There are two types of query parameters binding in the Hibernate Query. One is
Is there a way to query the current DATEFORMAT SQLServer 2005 is currently using
Is there a way to query the database and retrieve a list of all
Is there a way to query a full text index to help determine additional
Is there a way to query a MySQL database that gives me all blobs

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.