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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:30:13+00:00 2026-06-01T08:30:13+00:00

I have folowing MYsql Query And Trying to right outer join but unable to

  • 0

I have folowing MYsql Query And Trying to right outer join but unable to understan how to do this

here is query plase any one help

select lp_des.lpname,today.cnt_veh_tdy,todate.cnt_veh_tdate
from
(select distinct registration.lpcode,loadingpoint.lpname 
from registration,loadingpoint
where registration.lpcode=loadingpoint.lpcode) lp_des,
(select lpcode,count(vehicleno) cnt_veh_tdate
from registration
where registration.companycode='01'
group by lpcode) todate,
(
select lpcode,count(vehicleno) cnt_veh_tdy
from registration
where registration.companycode='01'
and registration.date=(select max(date) from registration)
group by lpcode) today
right outer join today on lp_des.lpcode = today.lpcode
right outer join todate on lp_des.lpcode = todate.lpcode

I want to make right outer join on this part

where lp_des.lpcode=todate.lpcode
and   lp_des.lpcode=today.lpcode

Please help and Thanks in advance

  • 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-01T08:30:15+00:00Added an answer on June 1, 2026 at 8:30 am

    You asked for this:

    select 
      lp_des.lpname,
      today.cnt_veh_tdy,
      todate.cnt_veh_tdate
    from
      (select distinct 
        r.lpcode,
        l.lpname 
      from 
        registration r
        inner join loadingpoint l on l.lpcode = r.lpcode) lp_des
      right join
        (select 
          r.lpcode,
          count(r.vehicleno) cnt_veh_tdate
        from 
          registration r
        where 
          r.companycode='01'
        group by 
          lpcode) todate on todate.lpcode = lp_des.lpcode
      right join
        (select 
          r.lpcode,
          count(r.vehicleno) cnt_veh_tdy
        from 
          registration r
        where 
          r.companycode = '01'
          and registration.date = (select max(date) from registration)
        group by 
          r.lpcode) today on today.lpcode = lp_des.lpcode
    

    But I think you mean this:

    select
      r.lpcode,
      l.lpname,
      count(r.vehicleno) cnt_veh_tdate,
      count(case when r.date = md.date then r.vehicleno else null end) cnt_veh_tdy
    from
      registration r
      inner join (select max(rm.date) maxdate from registration rm) md
      left join loadingpoint l on l.lpcode = r.lpcode
    where
      r.companycode = '01'
    group by 
      r.lpcode
    

    and maybe even this:

    select
      r.lpcode,
      l.lpname,
      count(r.vehicleno) cnt_veh_tdate,
      count(case when r.date = date() then r.vehicleno else null end) cnt_veh_tdy
    from
      registration r
      left join loadingpoint l on l.lpcode = r.lpcode
    where
      r.companycode = '01'
    group by 
      r.lpcode
    

    If I read it correctly, you want a query that returns the number of vehicles for company 1 assigned to a loading point, overall as well as for today only. And you also want that count for vehicles that do not have loading point assigned yet.
    Though it would help if you would have added this description. It will help the ones answering your question, but it will also help you writing the right query in the first place.

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

Sidebar

Related Questions

I have the following MySQL query statement: SELECT * FROM table1 INNER JOIN table2
I have the following query which works fine with MySQL but refuses to work
I'm trying to use natural join to join two tables in mySQL that have
I have the following MySQL query that I'm trying to translate into an equivalent
I'm trying to do this IF statement in a mySQL query which I learnt
I have the following mysql query which I am running with php like so.
I have the following mysql query: $manufacturers_query = select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from
I have an application that executes the following MySQL query: SELECT 402 AS user_id,
I have following query and data saved in a MySQL database with a timestamp
I'm using MySQL and I'm trying to construct a query to do the 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.