473,669 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding result tables together

Hi,

I have a query that gives me almost the results I want, which is

SELECT ai.entry_date as CallTime,
ai.agent_login as AgentsLogin,
ai.campaign as MarketingCampai gn,
ai.agent_input2 as ProductsSold,
ai.first_name as Cust_FirstName,
ai.last_name as Cust_LastName,
ai.agent_input1 as Cust_PersonalNu mber,
ai.street_addre ss as Cust_AddressStr eet,
ai.city as Cust_AddressCit y,
ai.state as Cust_AddressSta te,
ai.zip as Cust_AddressZIP ,
rec.file_name as AgreementRecord ingFile
FROM agent_input ai, leads l, recordings rec
WHERE ai.whole_phone_ number = l.whole_phone_n umber AND
l.call_status = 1110 AND
rec.whole_phone _number = l.whole_phone_n umber AND
rec.last_name = l.last_name AND
rec.agent = ai.agent_login AND
rec.campaign = l.campaign AND
last_call_date between #04/24/2006 12:00 AM# and #04/25/2006 11:59 PM#
ORDER BY ai.agent_login, ai.entry_date

but i want to make the rec.file_name as AgreementRecord ingFile
optional. Does any one know of a way I can modify the above to either
put '' in the results table or the rec.file_name if one is found? Im
sure this is some form of INTERSECT command, but i just keep getting
errors :(

FYI: This is to be run on a program which uses an access datafile as
its database, until we move to a mssql server in the near future. I
think the program is using odbc to access the access data file at the
moment.

Thanks for any help.

David

Apr 25 '06 #1
1 1731
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What errors are you getting?

What do you mean by "optional"? The value of the file_name column is
either there or not there (NOT NULL or NULL), unless you've allowed zero
length strings in the column, then the possibilities are NULL, NOT NULL,
or empty string. If you want to exclude any rows that have NULL in the
column just use a criteria in the WHERE clause:

WHERE....
AND rec.file_name IS NOT NULL

You can't include/exclude the column from the SELECT clause based on the
existence/non-existence of a value in the column - you'd have to write 2
different queries, one w/ the column and one w/o the column.

If this query is the source of an INSERT INTO command and the
destination column of the rec.file_name is a required column (NOT NULL)
then use the WHERE clause option. If the destination column accepts
zero-length strings (a horrible option, IMO) then use the IIf() function
to substitute a zero-length string:

IIf(rec.file_na me IS NULL,'',rec.fil e_name) AS AgreementRecord ingFile

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRE6dDoechKq OuFEgEQIinACgog/ySzRLNzirNEo9SB zZpnMx0pMAnRoW
JVt82hQSgbhVBZH aEfOb+ioh
=Y7vE
-----END PGP SIGNATURE-----
da************@ gmail.com wrote:
Hi,

I have a query that gives me almost the results I want, which is

SELECT ai.entry_date as CallTime,
ai.agent_login as AgentsLogin,
ai.campaign as MarketingCampai gn,
ai.agent_input2 as ProductsSold,
ai.first_name as Cust_FirstName,
ai.last_name as Cust_LastName,
ai.agent_input1 as Cust_PersonalNu mber,
ai.street_addre ss as Cust_AddressStr eet,
ai.city as Cust_AddressCit y,
ai.state as Cust_AddressSta te,
ai.zip as Cust_AddressZIP ,
rec.file_name as AgreementRecord ingFile
FROM agent_input ai, leads l, recordings rec
WHERE ai.whole_phone_ number = l.whole_phone_n umber AND
l.call_status = 1110 AND
rec.whole_phone _number = l.whole_phone_n umber AND
rec.last_name = l.last_name AND
rec.agent = ai.agent_login AND
rec.campaign = l.campaign AND
last_call_date between #04/24/2006 12:00 AM# and #04/25/2006 11:59 PM#
ORDER BY ai.agent_login, ai.entry_date

but i want to make the rec.file_name as AgreementRecord ingFile
optional. Does any one know of a way I can modify the above to either
put '' in the results table or the rec.file_name if one is found? Im
sure this is some form of INTERSECT command, but i just keep getting
errors :(

FYI: This is to be run on a program which uses an access datafile as
its database, until we move to a mssql server in the near future. I
think the program is using odbc to access the access data file at the
moment.

Apr 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2936
by: Sunny K | last post by:
Hi guys, I have a field in my DB called EventDate as a DateTime field, therefore it holds both the date and time together like this: '2004-10-14 08:42:57.000'. I need to add together all the times in this column for a particular date range (BETWEEN). Any suggestions will be great.
1
2746
by: E Arredondo | last post by:
Hi, I am about migrate from an old program database to MySql (Running under RH LINUX)and I'm wondering which is the best option to do : I currently have one file for each of my modules, (I'm using filepro plus) , so like CUSTOMER, WARRANTY, ZIPCODES, INV, etc... like 2,000 files each with their own fields. 1) Should I create multiple databases on MySQL
15
12363
by: crjunk | last post by:
I have 4 TextBoxes on my form that I'm trying to add together to get a grand total. Here is the code I'm using: <SCRIPT LANGUAGE="JavaScript"> <!-- Beginning of JavaScript - function calcTotalPub() { var tempFed = +document.Form1.value; var tempState = +document.Form1.value;
2
7671
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would like mine to run immediately after it. So in the code below, what JS would i need to add to my "myfile.inc" page so that I could guarantee this behavior? <!-- main page --> <html> <head> <script type="text/javascript">
0
1244
by: Tom Esker | last post by:
I have three linked tables that I can update individually but when I put them together into a query, I can no longer update the data. The tables are tied together with a field called "CASEID" which is unique in the "CASE" table but not unique in the other tables. The relationship is set to show all records in the CASE table and all matching records in the other two tables. Any idea what I need to do in order be able to update data in...
4
5477
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
2
5507
by: a | last post by:
I get the error that "Argument"1": cannot convert from 'string' to 'System.Data.DataRow' at the foreach loop to add rows to the DataTable...any ideas how to fix this? Paul ================================================== private void button1_Click(object sender, System.EventArgs e) {
17
12773
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
13
21508
by: moondaddy | last post by:
my understanding is that the max value of a byte is 255. Therefore, why does the following code get a compile error? byte val1 = 10; byte val2 = 23; byte ttl; ttl = val1 + val2; //this line wont compile compile error: Cannot implicitly convert type 'int' to 'byte'.
6
6554
by: santiago | last post by:
I guess one cannot do this: arraytot = arraytot + arraydet; So, what's the trick to adding arrays like this? Thanks.
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.