On 4/28/07, Victor Villa <[EMAIL PROTECTED]> wrote:

>Question:  What tools are available to kill the effects of the UNION
>function?  Here is an example of my return result....

John,

First, MS SQL isn't THAT bad.



I just wanted to show that I know this list isn't about MS products.  I do
what I can to avoid getting flamed.    =)

(See script below.)  As you can see I need to pull the Role and the Service
from the same field in the same table.  Almost all of the commonly used
descriptions/titles/phrases in our system are stored in
VSM180_MST_COD_DTL.cod_dtl_ds.
I don't know how to get both bits of information out in the same script
without using UNION.

I believe I knew what a left join was but I read the information you gave me
anyway.  I don't know if it's because it's too late in the evening or if
it's just plain inexperience but I'm still not getting how to use a left
join to get Role and Service without using UNION.

Please excuse this next newbie question...Is this enough information to go
off of?

SELECT   Lname = LTrim(VSM040_PERSON_HDR.lst_nm),
        Fname = LTrim(VSM040_PERSON_HDR.fst_nm),
        Caregiver_ID = VPM100_CARE_GIVER.car_gvr_ext_id,
        On_Staff = VPM100_CARE_GIVER.on_staf_fg,
        IP_Priv = VPM100_CARE_GIVER.ine_pat_adm_pvg_fg,
            Service = '',
            Roll = VSM180_MST_COD_DTL.cod_dtl_ds

   FROM VPM100_CARE_GIVER,
        VSM040_PERSON_HDR,
        VSM180_MST_COD_DTL

  WHERE VPM100_CARE_GIVER.car_gvr_int_id = VSM040_PERSON_HDR.psn_int_id and

        VPM100_CARE_GIVER.car_gvr_role_cd = VSM180_MST_COD_DTL.cod_dtl_int
_id

Union

Select   Lname = LTrim(VSM040_PERSON_HDR.lst_nm),
        Fname = LTrim(VSM040_PERSON_HDR.fst_nm),
        Caregiver_ID = VPM100_CARE_GIVER.car_gvr_ext_id,
        On_Staff = VPM100_CARE_GIVER.on_staf_fg,
        IP_Priv = VPM100_CARE_GIVER.ine_pat_adm_pvg_fg,
            Service = VSM180_MST_COD_DTL.cod_dtl_ds,
            Roll = ''

FROM VPM100_CARE_GIVER,
        VSM040_PERSON_HDR,
        VSM180_MST_COD_DTL

Where   VPM100_CARE_GIVER.car_gvr_int_id = VSM040_PERSON_HDR.psn_int_id and
           VPM100_CARE_GIVER.car_gvr_srv_cd =
VSM180_MST_COD_DTL.cod_dtl_int_id

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to