Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How do I filter all the data not in the list?

Author  Topic 

Vaishu
Posting Yak Master

178 Posts

Posted - 2008-04-28 : 07:41:28
Hi

I am using below code to fetch the data hit our webserver from different website or engine.

ex: If I pass the parameter Ref as google and the dates, will fetch the data (hits) from google.

I have created a table (PoList) to have names like google,amazon,aol upto 14 names.

My Question : How do I filter all (hits) the data which the name (Ref) is NOT in the PoList table.

Thanks in advance

CREATE PROCEDURE sp_Portals

@Ref as nvarchar(255),
@SDate as Decimal(18,0),
@EDate as Decimal(18,0)


AS

SELECT COUNT(b.Pcode) AS totclicks,
case when b.Pcode = 'NPF' then b.Pcode + '-- No Products Found'

else a.prodmodel
end as prodmodel,
SUM(c.orderTot) AS [Sales Total],
COUNT(c.cusID) AS NumSales,

b.Pcode as Code

FROM CusDetails c RIGHT OUTER JOIN
View1 b LEFT OUTER JOIN
Products a ON COALESCE (b.ProdID, 0) = a.ID ON c.sessID = b.SessID
WHERE (b.Referer LIKE '%' + @Ref+ '%') AND (b.theDate >= @SDate) AND (b.theDate <= @EDate)
GROUP BY b.Pcode, a.prodmodel
ORDER BY totclicks DESC
GO

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-28 : 08:03:11
Use NOT LIKE
Go to Top of Page

Vaishu
Posting Yak Master

178 Posts

Posted - 2008-04-28 : 09:04:07
Hi

I have a table name PoList like below

PoID----PoName
1 ------Google
2 ------Aol
3-------Amazon
4 ------Msn
5 ------Yahoo

I want to get data from other table where ref(PoName) is NOT in the Polist table. So If I use Not LIKE 'Ref(ex:google)', it will bring data with Aol,Amazon,Msn,Yahoo and OTHERS.

The reason I am doing this is, Polist table will grow in future. So I don't have to change the sqlprocedure and .Net coding all the time.


quote:
Originally posted by visakh16

Use NOT LIKE

Go to Top of Page
   

- Advertisement -