Author |
Topic  |
|
mike13
Posting Yak Master
Netherlands
219 Posts |
Posted - 12/18/2012 : 18:55:39
|
Hi All,
I'm struggling with this query:
SELECT TOP (100) PERCENT dbo.T_Product_Main.CategoryID, dbo.T_Order_Main.CustomerID, dbo.V_Top20_30days.ProductID, dbo.T_Order_Detail.ProductID AS customerproductid FROM dbo.T_Order_Main INNER JOIN dbo.T_Order_Detail ON dbo.T_Order_Main.ORDERID = dbo.T_Order_Detail.OrderID INNER JOIN dbo.T_Product_Main ON dbo.T_Order_Detail.ProductID = dbo.T_Product_Main.id INNER JOIN dbo.V_Top20_30days ON dbo.T_Product_Main.CategoryID = dbo.V_Top20_30days.CategoryID AND dbo.T_Order_Detail.ProductID <> dbo.V_Top20_30days.ProductID WHERE (dbo.T_Order_Main.CustomerID = 226869) GROUP BY dbo.T_Product_Main.CategoryID, dbo.T_Order_Main.CustomerID, dbo.V_Top20_30days.ProductID, dbo.T_Order_Detail.ProductID
i'm trying that dbo.T_Order_Detail.ProductID <> dbo.V_Top20_30days.ProductID
It only show productid that are V_Top20_30days and not in T_Order_Detail
doesn't seem to work, i get these results , as you can see product 355 should be there because it is in both Categoryid customerid productid customerproductid 1024 226869 355 2422 1024 226869 416 355 1024 226869 416 2422 1063 226869 421 2027 1011 226869 494 2720 1024 226869 521 355
any help, thanks a lot |
|
bandi
Flowing Fount of Yak Knowledge
India
2242 Posts |
Posted - 12/19/2012 : 00:37:30
|
Replace this part (AND dbo.T_Order_Detail.ProductID <> dbo.V_Top20_30days.ProductID) with the following:
AND dbo.V_Top20_30days.ProductID NOT IN (SELECT distinct ProductID FROM dbo.T_Order_Detail WHERE Product_id IS NOT NULL)
-- Chandu |
 |
|
visakh16
Very Important crosS Applying yaK Herder
India
52326 Posts |
|
mike13
Posting Yak Master
Netherlands
219 Posts |
Posted - 12/19/2012 : 04:24:51
|
mmm that doesn't produce any result |
 |
|
bandi
Flowing Fount of Yak Knowledge
India
2242 Posts |
Posted - 12/19/2012 : 04:32:40
|
quote: Originally posted by mike13
mmm that doesn't produce any result
Post your complete query once
-- Chandu |
 |
|
mike13
Posting Yak Master
Netherlands
219 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
India
52326 Posts |
|
gtopawb
Starting Member
5 Posts |
Posted - 12/27/2012 : 02:16:17
|
unspammed |
 |
|
|
Topic  |
|