Hello Everyone:
Here is my sql query, I'm MS SQL 7.0 accessing a sybase database. I need the result of my query to be by location_number but anytime I try to place the order by command SQL does not like it. Any ideas as to how I can get the resulting set of the union by location number.
Thanks.
DECLARE @clave int;
set @clave = "40003227";
SELECT
d.insured_loc_name,
d.insured_loc_street1,
d.insured_loc_street2,
d.insured_loc_city +', '+ d.insured_loc_state + ' '+ d.insured_loc_zip,
b.location_number,
c.insured_name
FROM wcps..wcps.policy_named_insured as a,
wcps..wcps.policy_insured_location as b,
wcps..wcps.insured_business as c,
wcps..wcps.insured_location as d
WHERE
( a.insured_business_id = d.insured_business_id ) and
( b.location_id = d.location_id ) and
( c.insured_business_id = a.insured_business_id ) and
( a.policy_id = @clave and b.policy_id = @clave )
union
select
null,
e.street_addr1,
e.street_addr2,
e.city + ', ' + e.state + ' '+ e.zip,
f.location_number,
e.insured_name
from wcps..wcps.insured_business as e,
wcps..wcps.policy_named_insured as f
where f.policy_id = @clave and f.insured_business_id = e.insured_business_id
Here is my sql query, I'm MS SQL 7.0 accessing a sybase database. I need the result of my query to be by location_number but anytime I try to place the order by command SQL does not like it. Any ideas as to how I can get the resulting set of the union by location number.
Thanks.
DECLARE @clave int;
set @clave = "40003227";
SELECT
d.insured_loc_name,
d.insured_loc_street1,
d.insured_loc_street2,
d.insured_loc_city +', '+ d.insured_loc_state + ' '+ d.insured_loc_zip,
b.location_number,
c.insured_name
FROM wcps..wcps.policy_named_insured as a,
wcps..wcps.policy_insured_location as b,
wcps..wcps.insured_business as c,
wcps..wcps.insured_location as d
WHERE
( a.insured_business_id = d.insured_business_id ) and
( b.location_id = d.location_id ) and
( c.insured_business_id = a.insured_business_id ) and
( a.policy_id = @clave and b.policy_id = @clave )
union
select
null,
e.street_addr1,
e.street_addr2,
e.city + ', ' + e.state + ' '+ e.zip,
f.location_number,
e.insured_name
from wcps..wcps.insured_business as e,
wcps..wcps.policy_named_insured as f
where f.policy_id = @clave and f.insured_business_id = e.insured_business_id