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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:48:18+00:00 2026-05-25T00:48:18+00:00

I’m here again with another question/problem. I know that topic’s title may be like

  • 0

I’m here again with another question/problem. I know that topic’s title may be like some others here, but I’ve noticed that they had another problems with that.

I have a problem with SQL LEFT JOIN. I’m using MySQL.

I want to have a table where TYPES would be for six months and calculations for one month (it might look strange, but I need it for some purposes).

I have two queries (I’ll show query and output that it would be more specific).

First query is for six months:

SELECT objectsoort AS types, COUNT(objectsoort) AS total, prijs AS price, SUM(prijs)/ SUM(oppervlakte) AS meters
FROM `huislijn`
WHERE <clause statements>
GROUP BY objectsoort

And I get result like this:

Six_months

Second query is for one month:

SELECT objectsoort AS types1, COUNT(objectsoort) AS total1, AVG(prijs) AS price1, SUM(prijs)/ SUM(oppervlakte) AS meters1
FROM `huislijn`
WHERE <clause statements>
GROUP BY objectsoort

Then I get result like that:

One month

I want to make them as one so I’m using LEFT JOIN and get query like that:

SELECT a.types1, b.total1, b.price1, b.meters1
FROM (SELECT objectsoort AS types1
FROM  `huislijn` 
WHERE <clause statements> ) a
LEFT JOIN
(SELECT objectsoort AS types12, COUNT( objectsoort ) AS total1, AVG( prijs ) AS price1, SUM( prijs ) / SUM( oppervlakte ) AS meters1
FROM `huislijn` 
WHERE <clause statements> ) b
ON a.types1 = b.types12
GROUP BY types1

BUT the result isn’t what I’ve expected, because there should be some result near ‘appartement’ and ‘woning’ results isn’t the same as in query for one month:

both in one

I repeat that it would be more clearly: I want types of six months and calculations for one month. In this case it means that results should be near ‘appartement’ and ‘woning’.

So, I wanted to know, maybe I’m doing something wrong.

Thanks for your help and support.

  • 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-25T00:48:18+00:00Added an answer on May 25, 2026 at 12:48 am

    Ok, I was asked to share solution, so here it is:

    As cularis said, I was missed GROUP BY objectsoort in some places. There’s the working query (I’ve changed it a bit, because working on it, but result is still the same):

    SELECT a.types5, b.total5, b.price5, b.meters5, a.total, a.price, a.meters
    FROM (
    SELECT objectsoort AS types5, COUNT(objectsoort) AS total, prijs AS price, SUM(prijs)/SUM(oppervlakte) AS meters
    FROM  `huislijn` 
    WHERE <clause statements>
    GROUP BY objectsoort ) a
    LEFT JOIN (
    SELECT objectsoort AS types15, COUNT(objectsoort) AS total5, AVG(prijs) AS price5, SUM(prijs)/SUM(oppervlakte) AS meters5
    FROM `huislijn`
    WHERE <clause statements>
    GROUP BY objectsoort ) b
    ON a.types5 = b.types15
    GROUP BY types5
    

    The result:

    result

    Thanks for cularis!

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.