|
From: nLL on 22 Jul 2008 04:44 -snip- if (@TotalInTodayFromSameIp<10) and (@PublisherLastEranedDifferance > 10) and (NOT @PublisherLastInAgent=(a)browser) and (NOT @PublisherLastInIp=(a)ip) and (@selectedid is not null) BEGIN -snip above IF runs query below BEGIN when all matches (obviously) i want to make (NOT @PublisherLastInAgent=(a)browser) (NOT @PublisherLastInIp=(a)ip) NOT mandatory IF @PublisherLastEranedDifferance > 10 I believe i should add OR somewhere but I'm getting confused.
From: dave ballantyne on 22 Jul 2008 05:06 If you're haveing trouble writing it now , you're have trouble understanding it when you come to look at it again in X years time. Break it down to nested ifs, itll be best in the long run Dave nLL wrote: > -snip- > if > (@TotalInTodayFromSameIp<10) > and (@PublisherLastEranedDifferance > 10) > and (NOT @PublisherLastInAgent=(a)browser) > and (NOT @PublisherLastInIp=(a)ip) > and (@selectedid is not null) > BEGIN > -snip > > above IF runs query below BEGIN when all matches (obviously) > i want to make > > (NOT @PublisherLastInAgent=(a)browser) > (NOT @PublisherLastInIp=(a)ip) > > NOT mandatory IF @PublisherLastEranedDifferance > 10 > > > I believe i should add OR somewhere but I'm getting confused.
From: Erland Sommarskog on 22 Jul 2008 05:19 nLL (no(a)onehere.nll) writes: > -snip- > if > (@TotalInTodayFromSameIp<10) > and (@PublisherLastEranedDifferance > 10) > and (NOT @PublisherLastInAgent=(a)browser) > and (NOT @PublisherLastInIp=(a)ip) > and (@selectedid is not null) > BEGIN > -snip > > above IF runs query below BEGIN when all matches (obviously) > i want to make > > (NOT @PublisherLastInAgent=(a)browser) > (NOT @PublisherLastInIp=(a)ip) > > NOT mandatory IF @PublisherLastEranedDifferance > 10 This may be what you are looking for: if @TotalInTodayFromSameIp <10 AND @selectedid is not null AND (@PublisherLastEranedDifferance > 10 OR @PublisherLastInAgent <> @browser AND @PublisherLastInIp <> @ip) I removed unneeded parens and also replace NOT = with <>, to make it a little easier. -- Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
From: nLL on 22 Jul 2008 05:18 dave ballantyne wrote: > If you're haveing trouble writing it now , you're have trouble > understanding it when you come to look at it again in X years time. > > Break it down to nested ifs, itll be best in the long run > > Dave > > > nLL wrote: >> -snip- >> if >> (@TotalInTodayFromSameIp<10) >> and (@PublisherLastEranedDifferance > 10) >> and (NOT @PublisherLastInAgent=(a)browser) >> and (NOT @PublisherLastInIp=(a)ip) >> and (@selectedid is not null) >> BEGIN >> -snip >> >> above IF runs query below BEGIN when all matches (obviously) >> i want to make >> >> (NOT @PublisherLastInAgent=(a)browser) >> (NOT @PublisherLastInIp=(a)ip) >> >> NOT mandatory IF @PublisherLastEranedDifferance > 10 >> >> >> I believe i should add OR somewhere but I'm getting confused. i done it with nested ifs but was trying to sort it in a one if
From: nLL on 22 Jul 2008 06:01 Erland Sommarskog wrote: > nLL (no(a)onehere.nll) writes: >> -snip- >> if >> (@TotalInTodayFromSameIp<10) >> and (@PublisherLastEranedDifferance > 10) >> and (NOT @PublisherLastInAgent=(a)browser) >> and (NOT @PublisherLastInIp=(a)ip) >> and (@selectedid is not null) >> BEGIN >> -snip >> >> above IF runs query below BEGIN when all matches (obviously) >> i want to make >> >> (NOT @PublisherLastInAgent=(a)browser) >> (NOT @PublisherLastInIp=(a)ip) >> >> NOT mandatory IF @PublisherLastEranedDifferance > 10 > > This may be what you are looking for: > > if @TotalInTodayFromSameIp <10 AND > @selectedid is not null AND > (@PublisherLastEranedDifferance > 10 OR > @PublisherLastInAgent <> @browser AND > @PublisherLastInIp <> @ip) > > I removed unneeded parens and also replace NOT = with <>, to make it a > little easier. > > > Thank you! Appreciated
|
Pages: 1 Prev: Script to fix sysdepends Next: IF and TRANSACTION problem |