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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:35:37+00:00 2026-05-17T19:35:37+00:00

after several attempts, I can not solve this problem. I have the following mysql

  • 0

after several attempts, I can not solve this problem.
I have the following mysql query:

SELECT
                  date_format(connect_time,"%Y-%m-%d %H") AS date,
                  NotConnected,
                  count(id) as calls,
                  sum(`duration`)/60 as minutes
   FROM test.`CDR_Vendors`,

   (SELECT        
       date_format(connect_time,"%Y-%m-%d %H") AS date,
       Count(id) as NotConnected
       FROM `CDR_Vendors_Failed`
       inner join Vendors on (CDR_Vendors_Failed.i_vendor = Vendors.i_vendor)
       inner join Customers on (CDR_Vendors_Failed.i_customer = Customers.i_customer)
       WHERE
       Customers.name like "W%"
       and
       Vendors.name like "D%"
       and connect_time between curdate() and now()
       GROUP by date
       ORDER BY date

   )Failed
       inner join Vendors on (CDR_Vendors.i_vendor = Vendors.i_vendor)
       inner join Customers on (CDR_Vendors.i_customer = Customers.i_customer)
       WHERE
       Customers.name like "W%"
       and
       Vendors.name like "D%"
       and connect_time between curdate() and now()
       GROUP by date
       ORDER BY date

The result:

date,Notconnected,calls, minutes
'2010-10-25 00', 408, 900, 6611.00
'2010-10-25 01', 408, 456, 2777.60
'2010-10-25 02', 408, 204, 1545.80
'2010-10-25 03', 408, 108, 1951.80
'2010-10-25 04', 408, 192, 895.60
'2010-10-25 05', 408, 300, 544.20
'2010-10-25 06', 408, 540, 961.20
'2010-10-25 07', 408, 1728, 5027.60
'2010-10-25 08', 408, 4968, 20986.40
'2010-10-25 09', 408, 7884, 33065.00
'2010-10-25 10', 408, 7836, 28182.20
'2010-10-25 11', 408, 1800, 3587.80

I noticed that the first value of Notconnected field is repeated.

how can I fix this please ?

  • 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-17T19:35:38+00:00Added an answer on May 17, 2026 at 7:35 pm

    This query will be very slow. In which table do you have connect_time field? If in CDR_Vendoes and CRD_Vendors_Failed, then you don’t need subquery.

    Maybe you need join with CDR_Vendors_Failed table?

    SELECT
                      date_format(connect_time,"%Y-%m-%d %H") AS date,
                      Failed.NotConnected,
                      count(id) as calls,
                      sum(`duration`)/60 as minutes
       FROM test.`CDR_Vendors`
           inner join Vendors on (CDR_Vendors.i_vendor = Vendors.i_vendor)
           inner join Customers on (CDR_Vendors.i_customer = Customers.i_customer)
           inner join
              (SELECT        
                   date_format(connect_time,"%Y-%m-%d %H") AS date,
                   Count(id) as NotConnected
                   FROM `CDR_Vendors_Failed`
                   inner join Vendors on (CDR_Vendors_Failed.i_vendor = Vendors.i_vendor)
                   inner join Customers on (CDR_Vendors_Failed.i_customer = Customers.i_customer)
                   WHERE
                   Customers.name like "W%"
                   and
                   Vendors.name like "D%"
                   and connect_time between curdate() and now()
                   GROUP by date
                   ORDER BY date
                )Failed on Failed.date = date_format(connect_time,"%Y-%m-%d %H")
           WHERE
           Customers.name like "W%"
           and
           Vendors.name like "D%"
           and connect_time between curdate() and now()
           GROUP by date
           ORDER BY date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After several failed attempts using ExtJS I have now decided to use javascript.The requirement
I've tried to do this several times with no luck. After reading this post
I'm trying to implement the Sieve of Eratosthene in C++. However after several attempts
coming back to postgresql after several years of oracle ... what are the state-of-the
I must be dense. After asking several questions on StackOverflow, I am still at
I'm creating an API for a module and after I created several methods inside
After using AS2 for several years, I'm getting started with writing applications in AS3
Suppose there were several projects mostly maintained by smart interns, who eventually leave after
After reading this question , I was reminded of when I was taught Java
I'm not sure if Youtube is the only website with this technology, but content

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.