08-27-2007, 1:43 PM
|
vojko
Joined on 08-28-2007
Posts 1
|
DateTime fields in GROUP BY, manual relations and offline data
|
 
 
|
|
|
Hi,
1.
Is it possible to make OQL statements for DateTime fields,
statements to extract grouped data like to get average per day over one month or similar.
Here is an examples of MS SQL statement, where we get
grouped records of sum,max,...., per ours:
Also pay attention to DATEPART function ....
'SELECT
DATEPART([YEAR], MyDateTimeFieldName') AS MyYEAR,
DATEPART([MONTH], MyDateTimeFieldName') AS MyMONTH,
DATEPART([DAY], MyDateTimeFieldName') AS MyDAY,
DATEPART([HOUR], MyDateTimeFieldName') AS MyClock,
COUNT(*) AS NumberOfGroupedRecords,
SUM(FLD1) AS MySUM,
MAX(FLD2) AS MyMAX,
CASE TARIFA
WHEN 1 THEN ''KT''
WHEN 2 THEN ''VT''
WHEN 3 THEN ''MT''
END AS MyTarifa
FROM MYTABLE
WHERE
(DATEPART([YEAR], MyDateTimeFieldName') = '+CAST(@Leto AS char(4))+' ) AND
(DATEPART([MONTH], MyDateTimeFieldName') = '+CAST(@Mesec AS char(2))+' ) AND
(DATEPART([DAY], MyDateTimeFieldName') = '+CAST(@Dan AS char(2))+' )
GROUP BY
DATEPART([YEAR], MyDateTimeFieldName'),
DATEPART([MONTH], MyDateTimeFieldName'),
DATEPART([DAY], MyDateTimeFieldName'),
DATEPART([HOUR], MyDateTimeFieldName') ,
TARIFA
ORDER BY MyClock
2.
Wondering if it is possible to make manual relationship between tables.
Many times we don't use DB's relations but make our own in the code.
3.
What is the easiest way to make offline data ?
To get ObjectDataSets and stream them to local files, XML or to local DB ?
thank you,
Kompozit EMRA d.o.o.
Vojko Cendak,univ.dipl.ing.
|
|
|
|
|
Report
|
|
|
|