We help IT Professionals succeed at work.
Get Started

star equal operator in implicit join

patd1
patd1 asked
on
119 Views
Last Modified: 2015-03-31
I have code in my stored proc that is using an implicit join along with *= operator, which I am converting to explicit join and removing *= operator. Please suggest what is wrong in the following code conversion, as I am not getting the same results from both queries.

existing code:
SELECT c.policy,
       c.edition,
       Isnull(b.ulineID, a.ulineID)         AS ulineid,
       Isnull(b.dID, a.dID)                 AS did ,
       Sum(Isnull(a.prior_unit_count, 0))   AS prior_unit_count,
       Sum(Isnull(b.current_unit_count, 0)) AS current_unit_count
INTO   dbo.uc1
FROM   dbo.pmi1 a,
       dbo.cmi1 b,
       dbo.me1 c
WHERE  c.policy *= b.policy
       AND c.ulineID *= b.ulineID
       AND c.policy *= a.policy
       AND c.ulineID *= a.ulineID
GROUP  BY c.policy,
          c.edition,
          Isnull(b.ulineID, a.ulineID),
          Isnull(b.dID, a.dID)
ORDER  BY c.policy,
          c.edition,
          Isnull(b.ulineID, a.ulineID),
          Isnull(b.dID, a.dID)

Open in new window


converted code:
SELECT c.policy,
       c.edition,
       Isnull(b.uID, a.uID)                 AS uid,
       Isnull(b.dID, a.dID)                 AS did ,
       Sum(Isnull(a.prior_unit_count, 0))   AS prior_unit_count,
       Sum(Isnull(b.current_unit_count, 0)) AS current_unit_count
INTO   dbo.uc1
FROM   dbo.cmi1 b
       LEFT OUTER JOIN dbo.me1 c
                    ON c.policy = b.policy
                       AND c.uID = b.uID
       LEFT OUTER JOIN dbo.pmi1 a
                    ON c.policy = a.policy
                       AND c.uID = a.uID
GROUP  BY c.policy,
          c.edition,
          Isnull(b.uID, a.uID),
          Isnull(b.dID, a.dID)
ORDER  BY c.policy,
          c.edition,
          Isnull(b.uID, a.uID),
          Isnull(b.dID, a.dID)

Open in new window

Comment
Watch Question
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE