We have a page where we want to display 1 record per owner, even if there are multiple records per user..
The 4 tables are
Owner
Locations
Service
Maintainance
The maintainance table is where there may be multiple records per user, but all we need to know is that which owners are in there.. so if owner 1234 is in there 20 times, i just want to display 1 record for that owner. We have a select statement at the moment
that returns 3 records out of 7, but for this query it should always return only 1 record
select
a.timeStamp,
b.location_id,
b.location_address1,
b.location_city,
b.location_state_code,
b.location_postal_code,
c.owner_company_name,
d.service_rep_name
from maintenance a,locations b,owners c,service d
where
a.location_id=b.location_id
AND a.user_parent_id = d.service_rep_id
AND c.owner_id = b.owner_id
group by a.timeStamp,b.location_id,b.location_address1,b.location_city,b.location_state_code,b.location_postal_code,c.owner_company_name,d.service_rep_name
ORDER BY timeStamp DESC
Intermediate ASP.net User, Using VS2008/VS2010 with C# and SQL2005, SQL2008, Silverlight 3
---------------------
Mark as Answered if it helped
cubangt
Contributor
3052 Points
2402 Posts
Need assistance returning only 1 record while joining 4 tables to build that record of data
Dec 15, 2010 05:16 PM|LINK
We have a page where we want to display 1 record per owner, even if there are multiple records per user..
The 4 tables are
Owner
Locations
Service
Maintainance
The maintainance table is where there may be multiple records per user, but all we need to know is that which owners are in there.. so if owner 1234 is in there 20 times, i just want to display 1 record for that owner. We have a select statement at the moment that returns 3 records out of 7, but for this query it should always return only 1 record
---------------------
Mark as Answered if it helped