Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get rid of the rest of joined records?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00064157
Message ID:
00064366
Vues:
32
>>>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!
:)
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform