我想弄清楚編寫這個Sql查詢的最佳方法。 我需要獲得客戶發送給他們的促銷電子郵件的總數。因此,我們有一個存儲客戶信息的表格,一個存儲他們的登錄信息的表格和一個存儲發送給客戶的不同電子郵件的鏈接的表格以及一個記錄點擊的表格創建一個查詢來獲得計數和其他列
這是迄今爲止我所知道的。
Select Customer.CustomerId,
Customer.FirstName,
Customer.LastName,
Customer.email,
Customer.Phone
From Customer
Join LoginInformation
ON customer.CustomerId = LoginInformation.CustomerId
JOIN ProductLinks
ON LoginInformation.LoginId= ProductLinks.LoginId
現在我需要獲得總點擊每一個客戶都提出,它是其中具有以下的列
ClickID
ProductLinkID
LoginId
,我需要使用下面的輸出
Customer.CustomerId,
Customer.FirstName,
Customer.LastName,
Customer.email,
Customer.Phone,
Total Clicks (this can be a sum of all the porductlinks every clicked)
點擊表SQL和C#
使用count()和GROUP BY – adatapost 2012-01-06 05:25:30
請查看關於聲譽http://stackoverflow.com/faq#reputation的FAQ – gbn 2012-01-09 22:43:15