1

Topic: Explain to the beginner the logic of request

All good afternoon.
I study sql on one of sites.
The following example with request is set:
=============== SQL Execution Log ==============
| |
| SELECT * |
| FROM Orders |
| WHERE NOT ((odate = 10/03/1990 AND snum> 1002) |
| OR amt> 2000.00); |
| =============================================== |
| onum amt odate cnum snum |
| ------ -------- ---------- ----- ----- |
| 3003 767.19 10/03/1990 2001 1001 |
| 3009 1713.23 10/04/1990 2002 1003 |
| 3007 75.75 10/04/1990 2004 1002 |
| 3010 1309.95 10/06/1990 2004 1002 |
=================================================
I correctly understood, what the given request should eliminate from sampling all the line long, comprising odate = 10/03/1990 AND snum> 1002 or amt> 2000? I.e., if one of these parameters true the line in sampling is not displayed?
But if it so why in sampling the line was displayed
"onum amt odate cnum snum |
| ------ -------- ---------- ----- ----- |
| 3003 767.19 10/03/1990 2001 1001 |
, Comprising odate = 10/03/1990 AND snum> 1002?
In advance I thank for comments

2

Re: Explain to the beginner the logic of request

Alexyas wrote:

All good afternoon.
I study sql on one of sites.
The following example with request is set:

=============== SQL Execution Log ==============
| |
| SELECT * |
| FROM Orders |
| WHERE NOT ((odate = 10/03/1990 AND snum> 1002) |
| OR amt> 2000.00); |
| =============================================== |
| onum amt odate cnum snum |
| ------ -------- ---------- ----- ----- |
| 3003 767.19 10/03/1990 2001 1001 |
| 3009 1713.23 10/04/1990 2002 1003 |
| 3007 75.75 10/04/1990 2004 1002 |
| 3010 1309.95 10/06/1990 2004 1002 |
=================================================

I correctly understood, what the given request should eliminate from sampling all the line long, comprising odate = 10/03/1990 AND snum> 1002 or amt> 2000? I.e., if one of these parameters true the line in sampling is not displayed?
But if it so why in sampling the line was displayed
"onum amt odate cnum snum |
| ------ -------- ---------- ----- ----- |
| 3003 767.19 10/03/1990 2001 1001 |
, Comprising odate = 10/03/1990 AND snum> 1002?
In advance I thank for comments

do not forget to use TAGS, please. Protect sight and nerves  smile

3

Re: Explain to the beginner the logic of request

Alexyas;
On a question subject - recall De-Morgan's law , remove the brackets, get rid of negation - at once it becomes clear, on what conditions the data is selected...

4

Re: Explain to the beginner the logic of request

Alexyas wrote:

why in sampling the line

was displayed
Because someone compares field value ` odate ` and value of expression 10/03/1990=0.00167504.
It is necessary to frame date literals with inverted commas or to use explicit coercion of type.

5

Re: Explain to the beginner the logic of request

Akina wrote:

it is passed...
Because someone compares field value ` odate ` and value of expression 10/03/1990=0.00167504.
It is necessary to frame date literals with inverted commas or to use explicit coercion of type.

yes, and about correct instructions of string literals - it is not necessary to forget, certainly...

6

Re: Explain to the beginner the logic of request

Alexyas wrote:

But if it so why in sampling the line was displayed
"onum amt odate cnum snum |
| ------ -------- ---------- ----- ----- |
| 3003 767.19 10/03/1990 2001 1001 |
, Comprising odate = 10/03/1990 AND snum> 1002?

Here it is fulfilled

WHERE NOT ((odate = 10/03/1990 AND snum> 1002)

The line with snum <1002 is shown
But it is all it was meaningful, if there were inverted commas at ' 10/03/1990'
Open for itself data type DATE

7

Re: Explain to the beginner the logic of request

Semispirit;
Thanks.
I.e. I correctly understood that the given request can be translated so: "to Eliminate from an output of request of a line which contain odate = 10/03/1990 AND snum> 1002 or which to contain value snum> 1002?

8

Re: Explain to the beginner the logic of request

To show lines which do not satisfy to a condition (odate = 10/03/1990 AND snum> 1002)
OR (amt> 2000.00)