Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
V6s5, View Avg() the top nos. = first no. of same linei
Message
From
30/06/2003 05:04:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00805192
Message ID:
00805202
Views:
24
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all
>
>I have this typical requirement where I have to AVG() the Top line items which equal to the First Line item of the same set. to explain...
>
>
>iID  ParentID  Col 10  Col 13
>1    22        39.5    5.936
>2    22        39.5    6.002
>3    22        39.5    6.027
>4    22        43.5    6.078
>5    22        39.5    6.106
>
>
>Of the above I have to avg() col 13 based on the first reading of col 10 upto the readings of col 10 which are constant, but nothing after the breakage. ie. I have to avg(5.936, 6.002, 6.027) but not to avg 6.106 though col 10 equals to the first value. This is a child of the parent-child so I also have to take care of subset to ParentID 22 only as in this case.
>
>I hope I have been able to explain this.
>
>Please advise.
if seek(parentID,'child','fktag')
  select child
  lnCol10 = col10
  calculate avg(col13) ;
     while parentID=parent.parentID and col10 = lnCol10 ;
     to lnResult
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform