Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get rid of the rest of joined records?
Message
From
08/12/1997 09:03:41
Jeff Tucker
Mackinac Center For Public Policy
Midland, Michigan, United States
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00064157
Message ID:
00064414
Views:
31
>>>>I have the remote view
>>>>
>>>>SELECT Pftenants.tn_key, Pftenants.tn_pfkey, Pftenants.tn_tekey,;
>>>> Pftenants.tn_tenantname, Pftenants.tn_leaseterm,;
>>>> Pftenants.tn_leaseexpiry, Pftenants.tn_area, Pftenants.tn_percrent,;
>>>> Pftenrent.tr_rate, Pftenants.tn_spacetype,Pftenants.tn_dateentered,;
>>>> Pftenrent.tr_startdate, Pftenants.tn_vacant;
>>>> FROM dbo.PFTENANTS Pftenants, dbo.PFTENRENT Pftenrent;
>>>> WHERE Pftenants.tn_key = Pftenrent.tr_tnkey;
>>>> AND Pftenants.tn_pfkey = ?rv_pf.pf_key;
>>>> ORDER BY Pftenants.tn_tenantname, ;
>>>> Pftenrent.tr_startdate DESC
>>>>
>>>>which after the join gives me several records for the same tenant with different rates. I need just first record of them. How I can get rid of others in one view definition?
>>>
>>>If I understand what your asking I think I can help.
>>>
>>>Below is a view in which the GROUP BY option for the SELECT command is used to Group the results by a unique ID, which means that they are only listed once in the result set.
>>>
>>>SELECT Hours.cgroupid, Active.cproject, Active.caccount,;
>>> Active.cactivity, Hours.ddate, SUM(Hours.ntime), Hours.chourid;
>>> FROM projmain!hours INNER JOIN projmain!active ;
>>> ON Hours.cgroupid = Active.cgroupid;
>>> WHERE Hours.cempid = ?cPassID;
>>> GROUP BY Hours.cgroupid
>>>
>>>If you plan on changing data in the result set and sending the changes back to the server, I am not sure if my suggestion will help you.
>>>
>>>Jeff
>>
>>Thanks Jeff, I got the idea and tried it, but in client-server environment when I try to save the view it gives me "connectivity error" and asks one-by one for all other fields in the view to be included in GROUP BY condition. Didn't figure out why yet...
>
>I found the easy workaround without touching the remote view definition. To the method, which requeries the view and calculates the sums I added after REQUERY()
>INDEX on tn_tenantname TO _tn_tmp UNIQUE
>Bingo!
>:)

Great! I am glad you figured it out. Thanks for the information.

Jeff
Previous
Reply
Map
View

Click here to load this message in the networking platform