Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Where to go

$
0
0
The question
Display, by company, the company name, contact name and phone number for any payer who has no insureds.

(now, I believe a company is the payer, yet can still have no insureds, if that makes sense.)

The ERD
http://s23.postimg.org/5zo1dajw7/image.jpg

What I've tried
Code:

SELECT PAYER.COMPANY_NAME, CONTACT_NAME, PHONE_NUM
FROM PAYER
JOIN PLAN ON PAYER.PAYER_ID = PLAN.PAYER_ID
JOIN POLICY ON PLAN.POLICY_ID =POLICY.POLICY_ID
JOIN INSURED ON POLICY.POLICY_ID = INSURED.POLICY_ID
JOIN MORTAL ON INSURED.MORTAL_ID = MORTAL.MORTAL_ID

Yea, don't ask where i was going with this..........it isn't good

Code:

SQL> SELECT PAYER.COMPANY_NAME, PAYER.CONTACT_NAME, PAYER.PHONE_NUM
  2  FROM PAYER
  3  JOIN PLAN ON PLAN.PAYER_ID = PAYER.PAYER_ID
  4  JOIN POLICY ON POLICY.PLAN_ID = PLAN.PLAN_ID
  5  LEFT OUTER JOIN INSURED ON INSURED.POLICY_ID = POLICY.POLICY_ID
  6  WHERE
  7  INSURED.POLICY_ID IS NULL;

no rows selected

Thats the closest I could get,

INSURED TABLE
Code:

SQL> select * from insured;

INSURED_ID I  POLICY_ID  MORTAL_ID
---------- - ---------- ----------
      602 P        501        102
      603 s        501        103
      604 c        501        104
      605 p        502        105
      606 S        502        106
      607 C        502        107
      608 P        503        108
      609 c        503        109
      610 p        504        110
      611 C        504        111
      612 P        505        112
      613 s        505        113
      614 c        506        114
      615 C        506        115
      616 P        507        116
      617 S        507        117
      618 c        507        118
      619 p        508        119
      620 C        508        120

The thing is, Im trying to get a list of entites where there is no insurance likely a company from payer, then a mortal?

Attached Images
File Type: jpg zz.jpg (148.2 KB)

Viewing all articles
Browse latest Browse all 13329

Trending Articles