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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:26:16+00:00 2026-06-16T04:26:16+00:00

Here is my Mysql query SELECT COUNT(*) CallCnt,ANBCnt, t2.Duration,(ANB) Number, ((DATE_SUB(‘2012-12-10 05:22:30’, INTERVAL (SELECT

  • 0

Here is my Mysql query

SELECT COUNT(*) CallCnt,ANBCnt, t2.Duration,(ANB) Number,
  ((DATE_SUB('2012-12-10 05:22:30',
              INTERVAL (SELECT CONCAT(''',t2.Duration:0,''')) MINUTE_SECOND))) Mintime,
  ('2012-12-10 05:22:30') Maxtime,
  (1) TYPE,
  (t1.CallTypeId) 
FROM cdr_temp1_check t1
  INNER JOIN cdr_temp1_check_details t2 
  ON t1.CallTypeId=t2.CallTypeId
WHERE TimeStamp1 >= DATE_SUB('2012-12-10 05:22:30',
                              INTERVAL (SELECT CONCAT(''',t2.Duration:0,''')) MINUTE_SECOND) 
  AND TimeStamp1<='2012-12-10 05:22:30'
GROUP BY ANB 
  HAVING COUNT(*) > ANBCnt

Result returned is

    CallCnt  ANBCnt  Duration      Number  Mintime              Maxtime                TYPE  CallTypeId
-------  ------  --------  ----------  -------------------  -------------------  ------  ----------
    267      40        25      2042011234  2012-12-10 05:20:30  2012-12-10 05:22:30       1           5
    134      20        15      9895697970  2012-12-10 05:20:30  2012-12-10 05:22:30       1           3

Expected Result

    CallCnt  ANBCnt  Duration      Number  Mintime              Maxtime                TYPE  CallTypeId
-------  ------  --------  ----------  -------------------  -------------------  ------  ----------
    267      40        25      2042011234  2012-12-10 04:57:30  2012-12-10 05:22:30       1           5
    134      20        15      9895697970  2012-12-10 04:57:30  2012-12-10 05:22:30       1           3

Column showing issue is the Mintime which should be Maxtime minus Duration

  • 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-16T04:26:18+00:00Added an answer on June 16, 2026 at 4:26 am

    I suggest you to try a different approach.

    Given that maxtime is just a string that you are entering into the query. You could use DATE_SUB to substract the desired interval directly

    ((DATE_SUB('2012-12-10 05:22:30',
    INTERVAL t2.Duration MINUTE))) Mintime
    

    so your entire query would be:

    SELECT COUNT(*) CallCnt,ANBCnt,
    t2.Duration,(ANB) Number,
    ((DATE_SUB('2012-12-10 05:22:30',
    INTERVAL t2.Duration MINUTE))) Mintime,
    ('2012-12-10 05:22:30') Maxtime,(1) TYPE,
    (t1.CallTypeId) FROM cdr_temp1_check t1
    INNER JOIN cdr_temp1_check_details t2 ON t1.CallTypeId=t2.CallTypeId
    WHERE TimeStamp1>=DATE_SUB('2012-12-10 05:22:30',
    INTERVAL t2.Duration MINUTE) 
    AND TimeStamp1<='2012-12-10 05:22:30'
    GROUP BY ANB HAVING COUNT(*)>ANBCnt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im getting a funny MySQL error. Here's whats happening: query: SELECT COUNT(id) AS mycount
I need to count result rows of MySql query. here I extended TableGateway class
here is my mysql statement: $result = mysql_query(select count(*) from usersecurity where email='.$_SESSION['username'].'); echo
Here is my query: SELECT COUNT(`id`) FROM `comments` WHERE `user_id` != '1' -- Author
I have MYSQL query SELECT WEEKDAY(CreatedDate), COUNT(CreatedDate), CreatedDate FROM bug_List GROUP BY WEEKDAY(CreatedDate) But
Here is a simple query: SELECT COUNT(*) FROM m_bug_t WHERE date_submitted BETWEEN TO_DATE('2011-08-22','yyyy-mm-dd') AND
Here is my MySQL Query that im trying to execute. it keeps failing with
I am having trouble getting well formatted results from my mysql query. Here is
I have a problem with (for me to complicated) MySql query. Okay, here is
I have this query which works correctly in MySQL. More background on it here

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.