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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:34:19+00:00 2026-06-13T18:34:19+00:00

This code gives me a nice result. But I want to add in some

  • 0

This code gives me a nice result. But I want to add in some fields from another table, I’m not sure where to put the additioanal WHERE code…

select day, sum(diff) as total_diff
from (
select sub_meterID, date(`date`) as day, max(value) - min(value) as diff
from `sub_meter_data`
where date(`date`) > '2012-10-01'
   and sub_meterID in ('58984','58985','58986','58987')
group by sub_meterID, date(`date`)
) a
group by day

The additional fields I need to match up are:

othertable.meterID = sub_meter_data.sub_meterID

moretable.meterID = othertableID
  • 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-13T18:34:20+00:00Added an answer on June 13, 2026 at 6:34 pm
    select day, sum(diff) as total_diff
    from (
    select t1.sub_meterID, date(t1.`date`) as day, max(t1.value) - min(t1.value) as diff
    from `sub_meter_data` t1
    JOIN othertable t2 ON t1.sub_meterID=t2.meterID
    JOIN moretable t3 ON t2.ID=t3.meterID
    where date(t1.`date`) > '2012-10-01'
       and t1.sub_meterID in ('58984','58985','58986','58987')
    group by t1.sub_meterID, date(t1.`date`)
    ) a
    group by day
    

    Read more info about MySQL Joins here

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

Sidebar

Related Questions

I am not sure why this code (gives stackoverflow at runtime) compiles: import java.io.*;
This code gives me an empty result. I expect it to print out the
For one or another reason this code sample gives 48 hours instead of 24,
I'm trying this code to access a property but it gives me an error:
In this code, for vector size, n >=32767, it gives segmentation fault, but upto
update: the answer from virtualeyes (below) looks pretty nice: but now a bit code-sanititzing
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
this code gives an instant seg fault,I tried placing printf's all over, I even
This code gives me an error: uses SDL uses SDLGraphics uses SDLImage screen: unowned
I'm trying to set up a Backbone application. This code below gives to following

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.