Question: I have a table like

| Name | Call Count | Call Duration (sec) |
| --- | --- | --- |
| A | 2 | 0 |
| B | 3 | 52 |
| C | 3 | 0 |
| D | 5 | 78 |
| E | 2 | 21 |

I'm trying to exclude the records which are having Call Count is 3 and also Call Duration (sec) is 0.

The query which I have written

```
 SELECT *
 FROM Table 
 WHERE (Call Count != 3
 AND Call Duration (sec) != 0)

```

I'm getting output as

| Name | Call Count | Call Duration (sec) |
| --- | --- | --- |
| D | 5 | 78 |
| E | 2 | 21 |

The output which I require

| Name | Call Count | Call Duration (sec) |
| --- | --- | --- |
| A | 2 | 0 |
| B | 3 | 52 |
| D | 5 | 78 |
| E | 2 | 21 |

Thanks in Advance

Answer: 
You want:

```sql
SELECT *
FROM Table 
WHERE NOT (call_count = 3 AND call_duration = 0);

```

By the DeMorgan's Laws, this can be rewritten as :

```sql
SELECT *
FROM Table 
WHERE call_count <> 3 OR call_duration <> 0;

```

I would probably use the first version in practice, as it closely resembles your English language requirements.
Here is a simple way to approach is,

1. Select id's (**Name**) which we don't want on specific condition.

> 
> SELECT Name
> FROM *Table\_name*
> WHERE CallCount = 3 and callDuration = 0;
> 
> 
> 

2. Put above query in a sub-query, where we select only those records which are **NOT IN()** above query.

**So our final Query will be**

> 
> Select \* from *Table\_name* where Name not in(SELECT Name
> FROM *Table\_name*
> WHERE CallCount = 3 and callDuration = 0);
> 
> 
> 

**Output :**

| Name | Call Count | Call Duration |
| --- | --- | --- |
| A | 2 | 0 |
| B | 3 | 52 |
| D | 5 | 78 |
| E | 2 | 21 |

**I hope, this will help you.**

Thanks :)