Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select
Message
From
15/04/2016 11:56:58
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
15/04/2016 11:53:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01634840
Message ID:
01634843
Views:
35
>>>Hello all,
>>>
>>>I have a cursor generated by a bunch of SQL subqueries. The data in that cursor is primary keys.
>>>
>>>I want to be able to select three records in another cursor for each primary keys that are a part of that cursor.
>>>
>>>So Cursor with primary keys looks like this
>>>
>>>12354
>>>3456
>>>23
>>>
>>>Result that I would like to have
>>>
>>>12354 Whatever1
>>>12354 Whatever2
>>>12354 Whatever3
>>>3456 Something1
>>>3456 Something2
>>>3456 Something3
>>>23 Other1
>>>23 Other2
>>>23 Other3
>>>
>>>Can this be done with a SQL construct?
>>
>>Hi Denis,
>>
>>the cheapest way without brain squeezing:
>>
>>create cursor curhelp (i1 I)
>>append blank
>>append blank
>>append blank
>>
>>select;
>> cur1.*,;
>> Cur2.i1;
>> from yourcursor as Cur1;
>> inner join curhelp as Cur2;
>>  on .t.;
>> into cursor curTarget
>>
>>use in curhelp
>>
>
>It really looks like brain squeezing will be needed in this case :-)
>
>Thanks for the suggestion. Interesting solution but let me tell you more. In fact I should've given you more information to begin with. My bad.
>
>So like I said original cursor cursor contains primary keys.
>
>From that cursor I need to search for dates that are in another cursor. I need to get the most recent dates. Let's say 3 most recent dates.
>
>Cursor EmployeeId
>Contains primary keys for the employees that need to be searched.
>One field only : Primary key
>
>Cursor WasHere
>Contains all the dates the employees were here.
>Field could be : EmployeeId and DateEmployeeWasHere (format for date is YMD)
>
>
>Content of cursor EmployeeId
>124
>52
>
>Content of cursor WasHere
>
>124 2015/01/01
>124 2014/01/01
>124 2013/01/01
>124 2016/01/01
>52 2015/02/02
>52 2014/02/02
>52 2013/02/02
>52 2016/02/02
>
>The result that I want is :
>
>124 2016/01/01
>124 2015/01/01
>124 2014/01/01
>52 2016/02/02
>52 2015/02/02
>52 2014/02/02

Would it be possible to create some tables, attach it via zip it to the next message and name the fields you like to have worked on? It's much mor nice to think this way. If you mind to have it into open use PM
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform