私は次のクエリを持っています:
select distinct(ab.id)
from WidgetClicks ab
join ManufacturerWidgets aa
on ab.ManufacturerWidgetId = aa.Id
join ManufacturerRetailers ad
on aa.ManufacturerId = ad.ManufacturerId
join Products ac
on ab.ProductId = ac.Id
where ad.Enabled = 0
and ad.RetailerId = 189
and aa.ManufacturerId = 46
and aa.CountryId = 72
and ac.Id = 6914
and ab.CreatedAt >= '2011-10-31 00:00:00.000'
and ab.CreatedAt <= '2012-03-31 00:00:00.000'
enabled = 1でretailerIdを使用すると、すべきではないのにまったく同じ結果が得られます。結果ははるかに少なくなるはずです。
私はそれが何か簡単なことだと確信していますが、それは私を怒らせます!助けていただければ幸いです
編集:
私が実際に行う必要があるのは、基本的に結果を得るために3つのステートメントを書くことです。これもどのように行うかは定かではありませんが、これはステートメントが行う必要があることです(平易な英語で):
affiliateretailerテーブルから*を選択します。ここでmanufacturerid=46およびenabled=true
小売業者がmanufacturerid=46である上記の選択に残っているものである場合、manufacturerRetailerから*を選択します。
select * from widgetClicks join on retialer d where productid = abc and wc.CreatedAt> = '2011-10-31 00:00:00.000' and wc.CreatedAt <= '2012-03-31 00:00:00.000'
編集 **
右私は私が欲しいSQLクエリを持っています...
SELECT COUNT(*)
FROM WidgetClicks
WHERE CreatedAt >= '2011-10-31 00:00:00.000'
and CreatedAt <= '2012-03-31 00:00:00.000'
and ProductId = 6914
AND RetailerId in (
SELECT RetailerId
FROM AffiliateUpdateFiles auf
WHERE auf.Enabled = 1 AND auf.ManufacturerId = 46 and RetailerId <> 189
)
AND ManufacturerWidgetId in (
select id
from ManufacturerWidgets
where ManufacturerId = 46 and CountryId = 72
)
これがthugです-私は実際にLinqでそれを必要としています-誰かが私のためにそれを変換することができればそれはありがたいです...私は行くでしょう!