Databse Query!!!

liunx

Guest
i have a small problem in Query. I have a Table in database which stores the ON and OFF status of machines. If its ON I store the value as 1 and if its OFF I store the Values as 0.

Now the client wants the start and end time of a machine

The database fields are :
mid, Faultname, time, Date, Status

The status tells the ON and OFF state of the machine.

he wants the output in this fashion.
Fault Name - Date - Stopped on - Started On - Rectified time

Here the rectified time is the difference b/w start and stop. This has to be calculated from the code only.
Please let me know how to achieve this friends....

Thanks in advance

regards

Karthik.Ri have a small problem in Query. I have a Table in database which stores the ON and OFF status of machines. If its ON I store the value as 1 and if its OFF I store the Values as 0.

Now the client wants the start and end time of a machine

The database fields are :
mid, Faultname, time, Date, Status

The status tells the ON and OFF state of the machine.

he wants the output in this fashion.
Fault Name - Date - Stopped on - Started On - Rectified time

Here the rectified time is the difference b/w start and stop. This has to be calculated from the code only.
Please let me know how to achieve this friends....

Thanks in advance

regards

Karthik.R


depending on you're type of db then you might use the follow of MS-SQL.

update tblMachines set StartTime = GetDate(), State = 1 where MachineId = @MachineId


where @MachineId is an SQL stored procedure variable you do the same thing for the update of the off state. and then your :f16:
 
Back
Top