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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:30:43+00:00 2026-05-23T02:30:43+00:00

Here i wrote a query with left join table shipyard. There is no connection

  • 0

Here i wrote a query with left join table shipyard. There is no connection related to this table but its affecting the results when we joined or removed, The question is why ?
Mainly its affecting OrderBook and TotalShips column.

    select a.sbwynum,
        a.sbnam,
        a.deleted,
        sum(if ((sh.statuscod = 'O' or sh.statuscod = 'S') and (left (
        condeldat, 4) = '2011' or left (adjdeldat, 4) = '2011' or left (
        deldat, 4) = '2011'), sh.cgt, 0)) as CurrCgt,
        count(if ((sh.statuscod = 'O' or sh.statuscod = 'S') and (left (
        condeldat, 4) = '2011' or left (adjdeldat, 4) = '2011' or left (
        deldat, 4) = '2011'), 1, NULL)) as CurrShips,
        count(if (sh.statuscod = 'O', 1, NULL)) as OrderBook,
        count(if (sh.statuscod = 'S', 1, NULL)) as TotalShips,
        a.country as coucod,
        ct.counam,
        a.fulnam,
        a.status,
        a.stoclist,
        if (sh.statuscod = 'O', 1, 2) as StatusFlag
 from shipbuilder as a
      left join
      (select sbwynum, statuscod, condeldat, adjdeldat, deldat, cgt from
      `ship` s join shiptype st on s.wytypid = st.wytypid and st.forsearch
      = 'Y' and st.searchsb = 'Y' and deleted = 'N') sh on sh.sbwynum =
      a.sbwynum
      left join country ct on ct.coucod = a.country and ct.deleted = 'N'
      left join shipyard sy on a.sbwynum = sy.sbwynum and sy.deleted != 'Y' and
      sy.syclsid != 'B'
 where a.sbwynum != '' and
       a.deleted = 'N' and
       a.status != 'FV' and
       a.country = '365'
 group by a.sbwynum
 having a.deleted = 'N'
 order by sbnam

Thanks a lot…..

  • 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-23T02:30:44+00:00Added an answer on May 23, 2026 at 2:30 am

    Based on the comment, it means that you have a 1 to many relationship from shipbuilder to shipyard that falls within your join criteria. This should be solved with a select distinct.

    Edit The distinct should be applied within your count statements

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

Sidebar

Related Questions

Here's a Django model class I wrote. This class gets a keyerror when I
here's the stored procedure i wrote.In this proc p_subjectid is an array of numbers
Here is a related manager I wrote: class PortfolioItemManager(models.Manager): use_for_related_fields = True def extended(self):
Jeff Atwood wrote about this here , and while I understand the theoretical performance
I'm trying to write a query for a database that will left join a
I've got a query I wrote using a JOIN to display a summary using
I have tried solving this problem by posting other related questions here that focused
I've read similar questions here on stackoverflow, but the OP's table structure is never
I have this query and I know there is a better way to write
I'm trying to write a linq to object query in vb.net, here 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.