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

  • Home
  • SEARCH
  • 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 8857817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:41:07+00:00 2026-06-14T14:41:07+00:00

The following structure is how to envision this query. user_info – id int(11) –

  • 0

The following structure is how to envision this query.

user_info
    - id int(11)
    - email varchar(255)
    - regdate int(11)

statistics
    - id int(11)
    - playerid int(11)
    - timetopay int(11) 

All I want to do is get all unique emails from user_info then get the average of statistics.timetopay-user_info.regdate but in the same query.

SELECT AVG(s.timetopay-ui.regdate) as time_amount FROM user_info ui    
LEFT JOIN statistics s ON ui.id=s.playerid 
WHERE s.timetopay>'0' GROUP BY ui.email ORDER BY ui.id DESC LIMIT 1

Hopefully from the above snippet you’ll get the gist. I’m just trying to work out the average time it takes a user to pay some money but only if they have.

The above query does not quite work for me at the moment.

I’m having to use group by ui.email as users can have more than one account. Anyone know how I can achieve this in one query?

  • 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-14T14:41:08+00:00Added an answer on June 14, 2026 at 2:41 pm

    Is this what you’re looking for?

    select avg(daystakenavg) from (
      select avg(s.timetopay - u.regdate) as daystakenavg
      from user_info u
      join statistics s on (u.id = s.playerid)
      group by email
    ) t
    

    Note if the user hasn’t made in purchase it will not be displayed in the results. If you want it to then change it to a left join and add a coalesce to default to whatever value you want:

    select avg(daystakenavg) totaldaystakenavg from (
      select coalesce(avg(s.timetopay - u.regdate), 0) as daystakenavg
      from user_info u
      left join statistics s on (u.id = s.playerid)
      group by email
    ) t
    

    Additionally, I wouldn’t recommend to use ints as dates… there is a Date data type you should be using.

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

Sidebar

Related Questions

I have the following structure: class foo(object): class bar(object): def __init__(self, parent): self._parent=parent #this
my application has the following structure: public class Transaction { public int TransactionID {
Consider the following structure: IEnumerable<IEnumerable<int>> collection = new[] { new [] {1, 2, 3},
i have table with following structure, name (type: TEXT) price (type: INT) color (type:
Whether following structure declaration is right. typedef struct { int roll; int age ;
I have the following structure user_id int(11) right int(11) group_id int(11) value tinyint(1) And
I have following structure struct { int myData; int myAnotherData; }Value; struct AnotherStructure {
I have the following structure: private struct S_indiv { public int[] x; public int
Please note the following structure: /assets --> this dir shouldn't be ignored. but SOME
I have the following structure: <div class=parent> <div id=child1>Content here</div> <div class=child2>Content here</div> </div>

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.