Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grouping and SQL
Message
 
 
To
26/10/2004 10:06:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954532
Message ID:
00954550
Views:
12
This message has been marked as a message which has helped to the initial question of the thread.
Russell,

I don't believe there is an easy way to aggregate a list of values with a SQL, this is just easier done in a scan loop:
create cursor result ( Jobno i, DrwString c(254) )
select jobno, drawno ... into cursor temp1 order by 1,2
lnLastJob = -1 && some non-occuring value
lcStr = ""
scan
   if ( lnLastJob != temp1.JobNo )
      if ( ! empty( lcStr ) )
         insert into result values ( lnLastJob, substr( lcStr, 2 ) )
      endif
      lnlastJob = temp1.jobno
      lcStr = ""
   endif
   lcStr = lcStr + "," + transform( temp1.drawno )
endscan
insert into result values ( lnLastJob, substr( lcStr, 2 ) )
>I have a table that contains the following fields (in addition to other fields):
>
>Jobno   Drwno
>6378     1
>6378     2
>6378     3
>6390     1
>6390     2
>etc....
>
>
>Is there an SQL statement that would produce the following fields:
>
>Jobno     Drwstring
>6378      1,2,3
>6390      1,2
>etc....
>
>Can this be done with the 'Group By' command? If so, how?
>
>Thanks in advance for your help!
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform