您好我想删除下面的重复记录是我的查询:
WITH Records as
(SELECT intDiamondId, txtStockNo as txtStockNo, tblMstRapVendors.txtRapID, txtRealStockNo as txtRealStockNo1, txtShape,
fltCarat, txtCut, txtColor, txtClarity, fltPrice, fltRapPrice, fltRapPercentage, txtCertificate,
fltDepth, fltTable, txtGirdle, txtCulet, txtPolish, txtSymmetry, txtFluorescence, fltCrown, fltPavilion,
txtMeasurements,txtCertificateNo, flgApproved, flgSold, txtRapCode ,dtDateModified,txtUpdatedBy,txtcomments,
ISNULL(tblMstDiamonds.isActualImage,0) as isActualImage, ISNULL(flgblueprint,0) as flgblueprint, ISNULL(flgPerfect,0) as flgPerfect,
ROW_NUMBER() OVER (ORDER BY dtDateModified DESC) AS 'RowNumber'
FROM tblMstDiamonds WITH(NOLOCK)
LEFT JOIN tblMstRapVendors WITH(NOLOCK) ON tblMstRapVendors.txtRapVendorCode = tblMstDiamonds.txtOwner
WHERE intDiamondid IN (6855065) AND txtRealStockNo IN ('2186043908','2186043908') )
SELECT * FROM Records WHERE (RowNumber BETWEEN(1) AND 26 - 1)
请帮我解决这个问题。提前谢谢。
答案 0 :(得分:0)
在此,如果您有任何主键?或任何独特的领域?如果是,则使用DISTINCT
。
在表格中,列可能包含许多重复值;有时您只想列出不同的(不同的)值。
DISTINCT
关键字可用于仅返回不同(不同)的值。
SELECT DISTINCT column_name,column_name
FROM table_name;