Hello all!
I've searched the forum for I am sure my answer lies within somewhere, but I was unable to apply what I found to solve my question.
I have two tables:
tProspects
-id (autonumber)
-CLECNumber
-CompanyName
tContactslog
-id (autonumber)
-CLECNumber
-callDate
-CallResult.
I cannot figure out a join issue. . The tProspects is a complete customer list. The tcontactslog has each type of contact made to the customer with the CLECListNumber as the id in common. When a customer is contacted, contact log record is created. There are multiple contact records for a Customer though not all Customers have been contacted. I need to do two things:
1) return a table (query result) which shows me all of the prospects in tprospects that do not have “not interested” as a call result in tContacts
2) after filtering out the ones that have "not interested" in CallResult, return a result that which includes the most recent (ONLY) callresult and Calldate from tcontacts, if any there is anything.
I am using MS Access 2007.
Thanks.
6 1328
Hi, what do you consider as the most recent? Do you want to return any calls within the last 5 days? last day? Or just the single record with the most recent date?
To filter your results your query would be something like this: -
SELECT *
-
FROM tProspects INNER JOIN tContactslog ON tContactslog.CLECNumber = tProspects.CLECNumber
-
WHERE CallResult <> 'not interested'
-
Hello all!
I've searched the forum for I am sure my answer lies within somewhere, but I was unable to apply what I found to solve my question.
I have two tables:
tProspects
-id (autonumber)
-CLECNumber
-CompanyName
tContactslog
-id (autonumber)
-CLECNumber
-callDate
-CallResult.
I cannot figure out a join issue. . The tProspects is a complete customer list. The tcontactslog has each type of contact made to the customer with the CLECListNumber as the id in common. When a customer is contacted, contact log record is created. There are multiple contact records for a Customer though not all Customers have been contacted. I need to do two things:
1) return a table (query result) which shows me all of the prospects in tprospects that do not have “not interested” as a call result in tContacts
2) after filtering out the ones that have "not interested" in CallResult, return a result that which includes the most recent (ONLY) callresult and Calldate from tcontacts, if any there is anything.
I am using MS Access 2007.
Thanks.
If I am understanding you correctly, try - SELECT tProspects.CLECNumber, CompanyName, calldate,callresult
-
FROM tProspects INNER JOIN tContactslog ON tProspects.CLECNumber = tContactslog.CLECNumber
-
WHERE callresult <>"not interested” AND calldate>=[Date From];
The [Date From] will prompt for a user input and then show all records from that date where an interest was shown.
Welcome to The Scripts.
Great!
I'm halfway home!
This worked to exclude those customers that have expressed "not interested from my list. (I added the "Ordered Service" as an additional criterion)
SELECT *
FROM tCLECProspects AS t1
WHERE (((Exists (select * from tContactLog where (callresult= 'Not Interested' AND tContactLog.CLECListNumber= t1.CLECListNumber) or callresult= 'Ordered Service' AND tContactLog.CLECListNumber= t1.CLECListNumber ))=False));
Now, I am trying to return the contents of the "CallResult" record, if exists of course as not all customers will have been contacted on any day. But, I need only the latest ONLY CallResultfield/record (from tContactLog) for each customer that has been previously contacted and has not been finalized as "not interested" or "ordered service" (e.g. still an active prospect) ).
These results populate a continuous form so our folks can see a list of prospects to contact and see the result LAST contact made with that contact.
Great!
I'm halfway home!
This worked to exclude those customers that have expressed "not interested from my list. (I added the "Ordered Service" as an additional criterion)
SELECT *
FROM tCLECProspects AS t1
WHERE (((Exists (select * from tContactLog where (callresult= 'Not Interested' AND tContactLog.CLECListNumber= t1.CLECListNumber) or callresult= 'Ordered Service' AND tContactLog.CLECListNumber= t1.CLECListNumber ))=False));
Now, I am trying to return the contents of the "CallResult" record, if exists of course as not all customers will have been contacted on any day. But, I need only the latest ONLY CallResultfield/record (from tContactLog) for each customer that has been previously contacted and has not been finalized as "not interested" or "ordered service" (e.g. still an active prospect) ).
These results populate a continuous form so our folks can see a list of prospects to contact and see the result LAST contact made with that contact.
You will need to use the Max() aggregate function on your date field, in the SELECT clause.
You may have to split into two queries.
You will need to use the Max() aggregate function on your date field, in the SELECT clause.
You may have to split into two queries.
I was thinking that. I tried Max() or Top 1 (using a sort on date) a couple of different ways, but ended up with the latest for the entire table and not the last/latest for each distinct number found (e.g. last of multiple contacts to each customer in table)
I was thinking that. I tried Max() or Top 1 (using a sort on date) a couple of different ways, but ended up with the latest for the entire table and not the last/latest for each distinct number found (e.g. last of multiple contacts to each customer in table)
You will have to select specific fields e.g. customer and Max(calldate) and GROUP BY customer.
That should get you closer.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Prem |
last post by:
Hi,
I am having many problems with inner join. my first problem is :
1) I want to know the precedance while evaluating query with multiple
joins.
eg.
select Employees.FirstName,...
|
by: Preston Landers |
last post by:
Hello all.
I am trying to write a query that "just" switches some data around so
it is shown in a slightly different format. I am already able to do
what I want in Oracle 8i, but I am having...
|
by: jbm05 |
last post by:
Hi,
I'm curious about the computational complexity of a query I have. The
query contains multiple nested self left joins, starting with a simple
select, then doing a self left join with the...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Lumpierbritches |
last post by:
I'm trying to pull all the parents of a particular animal and I have my SQL
statement that says not supported and when I attempt to run the Query, I get
The SQL statement couldn't be executed...
|
by: Phil W |
last post by:
Hello,
I have set up my database in access using many to many relationships (it's
the good ol' books and authors one again). I've actually extended it to
include other people who contribute in...
|
by: khan |
last post by:
i have 2 queries totaldues and totalPayments
totaldues has 2 fileds(custID (Group By)
amountDue(sum of all invoices dues)
and totalPayments consist of CustID(Group By) and Amount_Paid(sum of
all...
|
by: gkellymail |
last post by:
the following query works fine:
select link.idx, link.x_table, link.x_id_a, link.x_id_z, a.strandid,
b.strandid
from link_detail, link, strand A, strand B
where link_detail.x_table =...
|
by: TC |
last post by:
I've used Access for many years. Several times, I've encountered a bug
which I refer to as the "Vanishing Joins" bug. When it happens, joins
vanish randomly from queries. More specifically, all...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |