SQLServerデータベースの一意の行を表示したい。とという2つのテーブルがUploadedData
ありDummyReportDetail
ます。これらのテーブルを結合したいのですが、distinctを使用して一意の行を取得できません。
これは私の質問です:
SELECT DISTINCT
D.TokenNo, D.UploadDate AS "Date", D.[Time],
D.SMSContent AS [Message], D.SMSType AS [SMS Type],
(SELECT COUNT(d.MobNo) FROM dbo.DummyReportDetail AS d
WHERE d.UploadDate = '31/12/2012' AND d.UserID = '2'
AND d.UserType = 'Reseller' AND d.TokenNo = U.TokenNo) AS "Count",
D.DStatus AS "Status"
FROM
dbo.DummyReportDetail AS D
INNER JOIN
dbo.UploadedData AS U ON D.TokenNo = U.TokenNo
WHERE
D.UploadDate = '31/12/2012' AND D.UserID = '2'
AND D.UserType = 'Reseller' AND D.TokenNo = U.TokenNo
ORDER BY
D.TokenNo DESC
このクエリの出力は次のとおりです。
Token-4 31/12/2012 11:23:59 AM संपादकीय Unicode 2 SUBMITED
Token-4 31/12/2012 11:24:9 AM संपादकीय Unicode 2 SUBMITED
Token-3 31/12/2012 10:21:31 AM TestSMS Normal 1 SUBMITED
しかし、私はこの出力が欲しいです:
Token-4 31/12/2012 11:24:9 AM संपादकीय Unicode 2 SUBMITED
Token-3 31/12/2012 10:21:31 AM TestSMS Normal 1 SUBMITED
助けてください...よろしくお願いします