-1
我想從表中的訂單,其中從表用戶列EMAIL_ID包含重複(行中的用戶與重複的郵件)列表的列表搜索ID。另一個表從重複
SELECT
o.[Email], o.[Email_Id], d.intCount
FROM (
SELECT [Email], COUNT(*) as intCount
FROM [Server].[dbo].[Table]
GROUP BY [Email]
HAVING COUNT(*) > 1
) AS d
INNER JOIN [Server].[dbo].[Table] o ON o.[Email] = d.[Email]
所以我也嘗試以下操作:
SELECT * FROM [Server].[dbo].[Orders]
WHERE [Email_Id] IN/
SELECT
o.[Email], o.[Email_Id], d.intCount
FROM (
SELECT [Email], COUNT(*) as intCount
FROM [Server].[dbo].[Users]
GROUP BY [Email]
HAVING COUNT(*) > 1
) AS d
INNER JOIN [Server].[dbo].[Users] o ON o.[Email] = d.[Email]
)
它返回一個只有一個表達式可以在選擇列表中指定當子查詢未與EXISTS介紹。
SELECT [Order_Is], (
SELECT
o.[Email], o.[Email_Id], d.intCount
FROM (
SELECT [Email], COUNT(*) as intCount
FROM [Server].[dbo].[Users]
GROUP BY [Email]
HAVING COUNT(*) > 1
) AS d
INNER JOIN [Server].[dbo].[Users] o ON o.[Email] = d.[Email]
)
as [Email_Id]
FROM [Server].[dbo].[Orders]
有了相同的結果:
與也試過。
任何想法我做錯了什麼?
謝謝!
接着說:SQL-server'標籤使用 –
語法中的第二次嘗試看起來很有希望,只有'IN'關鍵字需要同柱,沒有多列比較。 – krtek