Re: someone double-check me on this sql

  • From: Toon Koppelaars <toon.koppelaars@xxxxxxxxxxx>
  • To: ChrisDavid.Taylor@xxxxxxxxxxxxxxx
  • Date: Fri, 29 Jun 2012 08:23:20 +0200

Chris,
Basic logic from De Morgan (http://en.wikipedia.org/wiki/De_Morgan's_laws
)....

"not X and not Y" is equivalent to "not (X or Y)", which would be
"not(month=5 or year=2012) in your first query.

Likewise, in your second query:

"not X or not Y" is equivalent to "not (X and Y)", which would be
not(monty=5 and year=2012)


Toon


On Fri, Jun 29, 2012 at 4:35 AM, Taylor, Chris David <
ChrisDavid.Taylor@xxxxxxxxxxxxxxx> wrote:

> I'm  a bit fuzzy at the moment due to pain meds after a minor surgery so
> I'm hoping someone can spot my error (if I have an error)
>
> Table has months, years and 'x' number of rows for each
>
> The table has Years 2011 and 2012
> In 2011, it has months 1-12
> And in 2012 it has months 1-5
>
> I run this:
> Select month, year, count(*) -- month, and year are actual column names
> From some_table
> Where (month != 5 and year != 2012)
> Group by month, year
> /
>
> The data set I get is Months 6-12 for 2011 *ONLY*
>
> Shouldn't that query *ONLY* exclude MONTH=5 and YEAR 12 together?
>  (instead of ALL 2012 and ALL 5s?)
>
>
>
>
> Chris Taylor
>
> "Quality is never an accident; it is always the result of intelligent
> effort."
> -- John Ruskin (English Writer 1819-1900)
>
> Any views and/or opinions expressed herein are my own and do not
> necessarily reflect the views of Ingram Industries, its affiliates, its
> subsidiaries or its employees.
>
>
>
>
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


-- 
Toon Koppelaars
RuleGen BV
Toon.Koppelaars@xxxxxxxxxxx
www.RuleGen.com
TheHelsinkiDeclaration.blogspot.com

(co)Author: "Applied Mathematics for Database Professionals"
www.rulegen.com/am4dp-backcover-text


--
//www.freelists.org/webpage/oracle-l


Other related posts: