Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to GROUP BY ....
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01531746
Message ID:
01531748
Views:
38
>Hello All,
>
>I have a datalogger that 'sends me' the readings in a .CSV file, and this is how I convert it to a FoxPro table/cursor with the intention of using FoxCharts to display the results.
>
>
>CREATE CURSOR CPdata ( ;
>	RType C(24), ;
>	Dtyme C(20), ;
>	MilliSec N(12,4), ;
>	ExcelTyme N(16,8), ;
>	DCreading N(16,7), ;
>	DCunit C(2), ;
>	ACreading N(16,7), ;
>	ACunit C(2), ;
>	TempRead N(6,1), ;
>	TempUnit C(2), ;
>	BattPot N(4,1), ;
>	GPSLat N(12,8), ;
>	GPSLon N(12,8), ;
>	GPSSat N(4), ;
>	CPNote C(48) )
>SELECT CPdata
>cCPdataFyle = [C:\TEMP\UDL1_DATA\TESTDATA.CSV]
>APPEND FROM (cCPdataFyle)  TYPE CSV
>BROWSE  TITLE cCPdataFyle
>
>This part of the code works just as I expect it should.
>The challenge is the quantity of data that is being saved and therefore must be displayed on the chart - 1 reading per second. 3600 readings per hour, 86400 per day. I'm trying to distill the data by averaging 10 readings into 1 number for display purposes using a SQL select:
>
>SELECT LEFT(Dtyme,18) AS Dtyme, AVG(DCreading) AS DCreading, ;
>	SPACE(10) AS cDate, SPACE(8) AS cHourMin ;
>FROM CPdata  WHERE RType=[DC] ;
>	GROUP BY Dtyme, cDate, cHourMin  ORDER BY dTyme ;
>	INTO CURSOR CPchart  READWRITE
>BROWSE  TITLE [Data to Chart]
>
>Problem: No grouping occurs (see attached screenshot).
>
>I'm missing something..... your assistance is appreciated.

Do you want to group by each hour? If so, GROUP BY LEFT(dType, 13).

If you want to group by date only, GROUP BY LEFT(dType,10)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform