Home > database >  The statistical
The statistical

Time:10-04

So I now have a task, is statistical call loss, and through to the number of per hour, the two data form
For example:
Time number number
15 0 0 13
1 100 1 89
2 1 45 50
,,,
Finally come out conclusion is to use the front in the table behind the number minus the number in the table, to form a new table is used to record each time period the number of call loss, the result should be how to write, please directly, thank you!

CodePudding user response:

Suppose your data window is regular, that's good to do, such as the former get data first, after the latter get data,
Then write an event in the latter, after calculating inserted in the table,

CodePudding user response:

Is a regular is from 0 to 23 PM, if but which events can after data retrieval result statistics and insert the new data window can be?

CodePudding user response:

If it is not your application directly to the, 2 it is to receive other equipment, and inserted into the database,
It is recommended to use the trigger,

CodePudding user response:

Time number number
15 0 0 13
1 100 1 89
2 1 45 50

Time, select a. a. number - isnull (b. number, 0) number from tb1 a
Left the join
(select time, sum number (quantity) from t2 group by time) b
On a. time=b.

Then using dynamic DW implementation.

CodePudding user response:

Dynamically created data window

In practical application, often need to dynamically according to user requirements to create the data window, a general method is that the
Add a data window in a window controls, such as dw_new, but there is no data the data window object, (blank) can use the following syntax to create:
Dw_new. Create (ls_syntax ls_error)//, create syntax error message
Ls_syntax can form with the following three methods:

A dynamic founded by SQL syntax:
//connected to the pb example database
String ls_sql ls_syntax, ls_error
Ls_syntax='select * from department'
Ls_syntax=sqlca. SyntaxFromSQL (ls_sql, 'style (type=grid)', ls_error)
If len (ls_error) & gt; 0 then
Messagebox (' Error 'and' SyntaxFromSQL Error: '~ r + ls_error)
The else
Dw_new. Create (ls_syntax ls_error)
If len (ls_error) & gt; 0 then
MessageBox (" Error ", "Create have these errors: ~ r" + ls_error)
The else
Dw_new. Settransobject (sqlca)
Dw_new. Retrieve ()
End the if
End the if

Second, by another data window syntax to create
String ls_syntax, ls_error
Ls_syntax=dw_test. The describe (' datawindow. Syntax)
Dw_new. Create (ls_syntax ls_error)
If ls_error & lt;> "' then
Messagebox (' Create Error, ls_error)
The else
Dw_new. Settransobject (sqlca)
Dw_new. Retrieve ()
End the if

Three, read PSR file to create
String ls_syntax ls_error, ls_ret
Ls_ret=char (13) + char (10)//enter key
Int li_fileNum
Long li_length
Li_FileNum=FileOpen (" efef. PSR ", Streammode! , read! , Shared! The Replace!

If li_filenum & gt; 0 then
FileSeek (li_FileNum, 158, FromBeginning!
Li_length=fileRead (li_filenum ls_syntax)
End the if
Fileclose (li_filenum)
If li_length=0 then return
Ls_syntax="release 5;" + + ls_syntax ls_ret

//removed ls_syntax data in a section, 5.0 "sparse (names=" dept_name?) "As a reference position
//6.0 HTML (
as a reference positionLong pos1, pos2
Pos1=pos (ls_syntax, 'point (names, 1)="'
Pos2=pos (ls_syntax, '"', pos1 + 16)
Ls_syntax=left (ls_syntax pos1) + mid (ls_syntax pos1 + 1, pos2 pos1 + 1)
Dw_New. Create (ls_syntax ls_error)
If ls_error & lt;> "' then
Messagebox (' Create Error, ls_error)
The else
Dw_new. Settransobject (sqlca)
Dw_new. Retrieve ()
End the if
//pb6, pb7 code can consult pb5 write their own, just different from the end tag file header and the data window,

CodePudding user response:

Original concept with the Create () function to Create dynamic data window, its Syntax format for: dw. The Create (Syntax [ErrString])
Among them: dw for to create dynamic data window; The Syntax of the string Syntax for creating dynamic data window; ErrString for optional parameters, used to store the error information when an error occurs, if suddenly
Slightly, errors occur when the system automatically displays a message box, generally does not conform to our needs, so need to define the parameters,

Clearly focused on Syntax, original concept to provide LibraryExport () and SyntaxFromSQL () function to achieve this goal: two

A, LibraryExport () function
Functions: an object from the output of the original concept library, return the object syntax,
Syntax format: LibraryExport (ObjName LibName, ObjType)
Among them: LibName for belt path the original concept of the library, if not specified path, search path search by system standard; ObjName for export object name, presently for the data in the LibName window
Object name; ObjType for the type of the object, now the data window, value of ExportDataWindow! , the sample is as follows:
String ls_DwSyntax, ls_Error
Ls_DwSyntax=LibraryExport (" C: \ PBExam \ dy_dw PBL ", "d_tbl1", ExportDataWindow!)
//data window dw_1 production will be discussed in more detail below, now temporarily slightly
Dw_1. Create (ls_DwSyntax ls_Error)
//the following statement with the same in the following example, thus slightly,
LibraryExport () function is to use the existing data window object to create dynamic data window, has certain use value, but few see,

Second, SyntaxFromSQL () function
Features: based on the SQL SELECT statement syntax to create data window,
Syntax format: Transaction. SyntaxFromSQL (SqlString StyleString, ErrorString)
. Among them: the Transaction for the connected Transaction object, the general is the SQLCA; SqlString for SQL - SELECT statement; Stylestring string for data window display style, more complex
Miscellaneous, commonly used "Style (Type=Grid)"; ErrorString used to store the error information when an error occurs,
In general, SyntaxFromSQL () function high flexibility, strong function, thus creating dynamic data window generally use this function, the following example is also use this function,

Three, to create the general steps of dynamic data window
Create dynamic data window general steps are as follows:
(such as 1, in a window w_main) use the mouse to point to build a data window control (e.g., dw_1), the DataObject is empty,
2, construct SyntaxFromSQL syntax string () function, it is the key to the original concept of dynamic data window, a little complicated, particular way please see the following example,
3, use the Create () function creates dw_1, dynamic data window and SetTransObject () function assigns the transaction object, particular way please see the following example,
The main drawback of this method is must first build data window control during the design phase, the runtime cannot increase and decrease, this for some of the more special applications (such as the design phase it needs a few data window)
Is not suitable, that how to solve this problem? After a fumble and looked up some information, finally found the two kinds of solution, are introduced respectively as follows: 1, create a standard visual data window user object u_d_sample
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related