Consult A SQL statement, such as A table has A few fields, this PVID, TransferDT, TransferReason, PVID for one person, (TransferReason) into and out of the hospital, TransferDT point in time for the family and discharge from the hospital
Check the time difference I know DATEDIFF (HH, 'the 2020-11-03 00:40:00. 000', '2020-11-03 09:40:00. 000') the actual parameters like this,
If you want to check all same for one person (PVID) from the division to the discharge time how to write, the average, every brother please grant instruction
CodePudding user response:
1, the date for the digital values "hours, minutes," such as 0920002 0May need date values for the digital calculation of
2, digital and, average
The result of the may need to be more than 60 minutes, 1 hour to
May need to define the decimal digits
3, redefined as date format
Maybe just let it be... If I could customize the function
CodePudding user response:
A person can have multiple hospital discharge timeCodePudding user response:
The SELECT PVID, AVG (DIFF) AS AVG_DIFF
The FROM
(SELECT Amy polumbo VID, DATEDIFF (HOUR, B.T ransferDT, A.T ransferDT) AS the DIFF
The FROM
(SELECT *, ROW_NUMBER OVER (PARTITION BY PVID ORDER BY TransferDT) AS SEQ FROM TABLE WHERE CHARINDEX (' hospital 'TransferReason) & gt; 0) AS A
The JOIN (SELECT *, ROW_NUMBER OVER (PARTITION BY PVID ORDER BY TransferDT) AS SEQ FROM TABLE WHERE CHARINDEX (' into the families' TransferReason) & gt;
0) AS BON Amy polumbo VID=p. VID AND A.S EQ=B.S EQ) AS C