你好我有两列
PR_PurchaseRequestHistory
1)uid
2)POUID
3)PRUID
4)PRDUID
5)CreatedDtTm
6)ModifiedDtTM
PO_PurchaseOrderDetails
1)uid
2)PRUid
3)RespondedDtTm
4)ModifiedDtTm
5)CreatedDtTm
为每个新请求分配(唯一PRUId),并为该PRUId下订单POUId。我需要获得为特定月份生成的ID的平均日期差异
我认为这可以解决问题 请帮帮我。我长期以来一直对这个问题感到震惊
答案 0 :(得分:0)
SELECT AVG(HOUR(TIMEDIFF(PO_PurchaseOrderDetails.RespondedDtTm, PR_PurchaseRequestHistory.CreatedDtTm)))
FROM PR_PurchaseRequestHistory
INNER JOIN PO_PurchaseOrderDetails ON PR_PurchaseRequestHistory.PRUID = PO_PurchaseOrderDetails.PRUID
WHERE MONTH(PR_PurchaseRequestHistory.CreatedDtTm) = 3 -- March
AND YEAR(PR_PurchaseRequestHistory.CreatedDtTm) = 2011