Hi,
Using VFP 9.0 to remotely query a SQL database and I'm stuck once again...
yeah I know, what else is new? :-)
This time I'm trying to make a sort of lookup table(view) from two related
tables:
Table name: billing_code
Fields:
sys_id (pk)
billing_code_set_ver_sys_id
billing_code
description
create_timestamp
modify_timestamp
create_user
modify_user
Table name: billing_code_charge_code
Fields:
sys_id (pk)
billing_code_sys_id
chg_codes_code
create_timestamp
modify_timestamp
create_user
modify_user
These tables are related on the billing_code.sys_id to billing_code_sys_id,
for every billing_code record there's many billing_code_charge_code records.
What I want is a table that returns chg_codes_code, billing_code and
description. Sounds simple doesn't it? Here's the catch...
The billing_code table is on the many side of a one to many relationship
with another table, billing_code_set_version. This means that there are
multiple records in billing_code with the same billing_code and description.
So far I haven't figured out how to get my query with just one record for
every chg_codes_code, billing_code and billing_code.description. The
closest I've gotten is this:
select distinct chg_codes_code, billing_code, description
from billing_code_charge_code
right join billing_code on billing_code.sys_id =
billing_code_charge_code.billing_code_sys_id
where left(chg_codes_code, 1) in ('D', 'F', 'E')
order by chg_codes_code
In many cases this returns duplicate chg_codes_code values. The main
difference I see in the records is that for one the description is in all
upper case and the description for the other record uses normal case.
Any suggestions? I've been trying all sorts of combinations but so far no
luck.
Thanks in advance,
Linn