0
Hello, in my select I need to find the average service time (TMA) between two columns BIGINT format being them:
Date: Dtbegin (start) and Dtend (end)
They are of the format "dd/mm/yyyyyy hh:mm:ss", I want to know in seconds how long each service lasted, I can not touch anything of the bank want only in the view.
Create Table
Create Table Interaction
IDInteraction bigint(20),
DtBegin datetime,
DtEnd datetime,
IDuser int(11),
IDSupervisor int(11),
OperatorName varchar(200),
SupervisorName varchar(200),
IDSession bigint(20),
IDMailingItem bigint(20),
IDContact bigint(20),
Notes longtext,
IDResult int(11),
ResultDescription varchar(100),
IDCampaign int(11),
CampaignDescription varchar(200),
IsAutomatic bit(1),
IDChannel int(11),
IsCallback bit(1)`
Insert
INSERT INTO Interaction (417,
'16/05/2016 20:00:40',
'16/05/2016 20:01:18',
1,
2,
'Fulano BR',
'SUPERVISOR 001',
null,
null,
4,
null,
2,
'AfterCallEnd',
1,
'Campanha SMS',
1,
9,
null);
Do you have any example of what this table is like with data and how it would be a result for example?
– novic
@Virgilionovic added an image of my select the result would be the difference of seconds between the beginning and the end, rotates around 1.04, 0.03 and so on
– Kaleb Gabriel
BIGINT columns in "dd/mm/yyyy hh:mm:ss" format? Columns are not DATETIME or VARCHAR?
– abfurlan
Kaleb made an issue, take a look at the answer and if that’s it... !!! the average in seconds?
– novic
@abfurlan are even bigint :/
– Kaleb Gabriel
Kaled I asked you a question what would be the result of a line? and another by TIME_TO_SEC will not roll like this!
– novic
The fields were not BIGINT? By the creation code of your table are datetime! :/
– abfurlan
Managed to solve, I also made an issue take a look!
– novic
@Virgilionovic I tried your code without the "from_unixtime" and it worked although I had already tried earlier kk thank you very much kk
– Kaleb Gabriel