![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. |
#3
| |||
| |||
|
|
Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. |
#4
| |||
| |||
|
|
Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. |
#5
| |||
| |||
|
|
Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. |
#6
| |||
| |||
|
|
On May 5, 9:17 am, Mtek <m... (AT) mtekusa (DOT) com> wrote: Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. But you show only one table in this query, customers_lookup. Here's a hint in the form of a question: What is the difference between the union operation and the join operation? hth, ed |
#7
| |||
| |||
|
|
On May 5, 9:17 am, Mtek <m... (AT) mtekusa (DOT) com> wrote: Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. But you show only one table in this query, customers_lookup. Here's a hint in the form of a question: What is the difference between the union operation and the join operation? hth, ed |
#8
| |||
| |||
|
|
On May 5, 9:17 am, Mtek <m... (AT) mtekusa (DOT) com> wrote: Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. But you show only one table in this query, customers_lookup. Here's a hint in the form of a question: What is the difference between the union operation and the join operation? hth, ed |
#9
| |||
| |||
|
|
On May 5, 9:17 am, Mtek <m... (AT) mtekusa (DOT) com> wrote: Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom UNION (SELECT count(DISTINCT(email)) FROM customers_lookup) ze UNION (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. But you show only one table in this query, customers_lookup. Here's a hint in the form of a question: What is the difference between the union operation and the join operation? hth, ed |
#10
| |||
| |||
|
|
On May 5, 8:46 am, Ed Prochak <edproc... (AT) gmail (DOT) com> wrote: On May 5, 9:17 am, Mtek <m... (AT) mtekusa (DOT) com> wrote: Hi, This is my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM * * (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom * * UNION * * (SELECT count(DISTINCT(email)) FROM customers_lookup) ze * * UNION * * (SELECT count(DISTINCT(email)) zp FROM customers_lookup) zp); Basically I want to get a count from the three tables where the email address appears in ALL THREE tables. *If an email does not exist in all three tables, then I do not want it counted....... I think I'm barking up the wrong tree with the query above...... John. But you show only one table in this query, customers_lookup. Here's a hint in the form of a question: What is the difference between *the union operation and the join operation? hth, * ed Well, I figured that UNION removed duplicates. *So, I was trying to get a count of the email addresses that exist in all three tables. *I made a mistake in my query: SELECT SUM(zcom) + SUM(ze) + SUM(zp) FROM * * (SELECT count(DISTINCT(email)) FROM customers_lookup) zcom * * UNION * * (SELECT count(DISTINCT(email)) FROM customers_lookup_ze) ze * * UNION * * (SELECT count(DISTINCT(email)) zp FROM customers_lookup_prim) zp); There are the three tables. So, I only want to include emails which are in all three tables for my counts.... Thanks for the reply. John- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |