我正在使用下面的查询来显示记录,但是如果提交的日期具有不同的时间戳,则查询将返回重复的记录 ex:(07/30/2012 08:13:00 PM and 07/30/2012 08:14:00 PM)
我需要时间戳同时显示在提交的日期中我不希望重复因为group by clause convert(datetime, convert(varchar(17), fac.SUBMISSION_DT, 116)).
它应该只采用日期部分而不是带有时间戳的日期任何有助于更改查询以适应此要求的帮助将不胜感激。
SELECT clm.REPRESENTATIVE as EMPLOYEE_ID , rep.USER_NM as EMPLOYEE_NAME,fac.SUBMITTED_BY as SUBMITTER_ID, srp.USER_NM as SUBMITTER_NAME,clm.CLAIM_AM as CLAIM_AM, sum(trn.ADJUSTED_AM) as SUBMITTED_AMOUNT,
**convert(datetime, convert(varchar(17), fac.SUBMISSION_DT, 116)) as SUBMITTED_DATE,**
csc.CLM_SCENARIO_DESC as SCENARIO_DESC, clm.CLAIM_TP as CLAIM_TP,fac.ACTION_ID as ACTION_ID, cac.ACTION_DESC as ACTION_DESC, clm.CLAIM_NB as CLAIM_NB, cmp.CLAIM_ID as CLAIM_ID,cust.CUST_SGMNT_ID as CUST_SGMNT_ID,(CASE WHEN sum(trn.adjusted_am) <= 100000 THEN 'Y' ELSE 'N' END) as APPROVABLE, clm.LIABILITY_60DAYS_FLAG as LIABILITY_60DAYS_FLAG
FROM LIB clm, Book trn, CUST cust, FIN fac, secdbp01..SEC_USER rep, secdbp01..SEC_USER srp, ADO_CLM_SCENARIO_CD csc, ADO_CLAIM_ACTIONS cac, LCM_CLAIM_MAP cmp
WHERE clm.CLAIM_NB = trn.CLAIM_NB AND
clm.CLAIM_NB = cust.CLAIM_NB AND
trn.STATUS_FLAG = 'P' AND trn.TRAN_DISP = 'F' AND
trn.CLAIM_NB = fac.CLAIM_NB AND
trn.POSTING_DT = fac.POSTING_DT AND
trn.TRANSACTION_ID = fac.TRANSACTION_ID AND
trn.BATCH_ID = fac.BATCH_ID AND
srp.USER_ID <> 'R300726' AND
clm.REPRESENTATIVE = rep.USER_ID AND
srp.USER_ID = fac.SUBMITTED_BY AND
clm.CLM_SCENARIO = csc.CLM_SCENARIO AND
clm.CLAIM_NB = cmp.REFERENCE_NUMBER AND
fac.ACTION_ID = cac.ACTION_ID AND
clm.PROGRESS_CD IN ('03','04','15') AND
isnull(clm.TRAINING_CLM_FLAG,'N') = 'N' AND
(clm.CLAIM_AM >= 0 AND
clm.CLAIM_AM <= 1000)
GROUP BY clm.REPRESENTATIVE, rep.USER_NM, fac.SUBMITTED_BY, srp.USER_NM, clm.CLAIM_AM,clm.CLAIM_NB,
**convert(datetime, convert(varchar(17), fac.SUBMISSION_DT, 116)),**
csc.CLM_SCENARIO_DESC,
clm.CLAIM_TP, fac.ACTION_ID, cac.ACTION_DESC, cmp.CLAIM_ID, cust.CUST_SGMNT_ID, clm.LIABILITY_60DAYS_FLAG
HAVING sum(trn.ADJUSTED_AM) <= 10000000
ORDER BY SUBMITTER_NAME asc