473,379 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

omit from select query

I have this select query :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU ORDER BY ReferredToLU.ReferredTo;
I would like to do two thing but not sure if they are possable or how to do them
1) using this query I would like to omitt the value "N/A" (w/o quotes)

2 ) omitt "N/A"(w/o quotes) and omite a persons name in a value in column [Referred to] where colume[status] does not equal "lead" (w/o quotes)

The reason, I have 3 tables with basicly the same info in them (all three are lookup tables)
thanks for help.
Mar 13 '08 #1
8 2223
n8kindt
221 100+
my suggestion would be to use the "totals" feature in your query. it's the button that sort of looks like an uppercase "E". perhaps u might even want to use a crosstab query. your microsoft help files should help you with the rest.
Mar 13 '08 #2
my suggestion would be to use the "totals" feature in your query. it's the button that sort of looks like an uppercase "E". perhaps u might even want to use a crosstab query. your microsoft help files should help you with the rest.
sorry that doesn't make much since to me, I don't have tabed pages, and as for the "E" button I have never seen it. The query is placeed in rowsoucre property of a combobox
Mar 13 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Trevor2007. The easiest way to do what you ask is to use the graphical query builder from the Access Queries tab and add criteria to the query fields. This is very quick and simple. You don't say what the type of [Referred To] is, but as it is storing a name it is certainly a string value, in which case you will need the quotes in the query criteria (all string literal values are listed in quotes).

You could place the following SQL in the SQL view of your query and then see what it looks like in the graphical design view:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU ORDER BY ReferredToLU.ReferredTo
  2. WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.Status <> "Lead"
You do not say which field holds the value "N/A" you wish to exclude. I have assumed it is the ReferredTo field, the only one returned in your sample SQL. Similarly, your request to omit a person's name when Status="Lead" is not meaningful when this is the only field returned by the query. For that reason the SQL I provided simply excludes matching rows altogether.

-Stewart
Mar 13 '08 #4
Hi Trevor2007. The easiest way to do what you ask is to use the graphical query builder from the Access Queries tab and add criteria to the query fields. This is very quick and simple. You don't say what the type of [Referred To] is, but as it is storing a name it is certainly a string value, in which case you will need the quotes in the query criteria (all string literal values are listed in quotes).

You could place the following SQL in the SQL view of your query and then see what it looks like in the graphical design view:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU ORDER BY ReferredToLU.ReferredTo
  2. WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.Status <> "Lead"
You do not say which field holds the value "N/A" you wish to exclude. I have assumed it is the ReferredTo field, the only one returned in your sample SQL. Similarly, your request to omit a person's name when Status="Lead" is not meaningful when this is the only field returned by the query. For that reason the SQL I provided simply excludes matching rows altogether.

-Stewart
yes, you assumed right , [referredTo] is a string value, it is the name of a person or team group.
I haven't tested it yet but am testing after I leave you this post.
Mar 14 '08 #5
yes, you assumed right , [referredTo] is a string value, it is the name of a person or team group.
I haven't tested it yet but am testing after I leave you this post.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU ORDER BY ReferredToLU.ReferredTo
  2.   WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.STATUS <> "Lead";
I am getting an error when i try to save the query in either the query graphical representation or if i try to use the query in a row sourc, the error is :
syntax error (missing operator ) in query expression 'referredtolu.referredto where referredtolu.referredto <> "N/A" AND referredtolu.status <> "Lead"
I have tried this this way and with add a semicolin to the end of "lead";
and still the same error
I have also tried tripple quoting my sting values ie '" [value]"'
and that didn't help
Mar 14 '08 #6
Stewart Ross
2,545 Expert Mod 2GB
[code]
SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU ORDER BY ReferredToLU.ReferredTo
WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.STATUS <> "Lead";
[code]

I am getting an error when i try to save the query in either the query graphical representation or if i try to use the query in a row sourc, the error is :
syntax error (missing operator ) in query expression 'referredtolu.referredto where referredtolu.referredto <> "N/A" AND referredtolu.status <> "Lead"
I have tried this this way and with add a semicolin to the end of "lead";
and still the same error
I have also tried tripple quoting my sting values ie '" [value]"'
and that didn't help
My apologies, I added the where clause and overlooked the ORDER BY clause which has to come last. The revised SQL should be
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.STATUS <> "Lead"
  2. ORDER BY ReferredToLU.ReferredTo;
-Stewart
Mar 14 '08 #7
My apologies, I added the where clause and overlooked the ORDER BY clause which has to come last. The revised SQL should be
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT ReferredToLU.ReferredTo FROM ReferredToLU WHERE ReferredToLU.ReferredTo <> "N/A" AND ReferredToLU.STATUS <> "Lead"
  2. ORDER BY ReferredToLU.ReferredTo;
-Stewart
I played with the query builder in graphical Display and came up with :, that seem to work
only to discomver I didn't need it, becacuse I needed the table just for one form :
Expand|Select|Wrap|Line Numbers
  1. SELECT ReferredToLU.ReferredTo
  2. FROM ReferredToLU
  3. WHERE (((ReferredToLU.ReferredTo)<>"N/A") AND ((ReferredToLU.Status)<>"Lead"))
  4. ORDER BY ReferredToLU.ReferredTo;
Thanks for your help
Mar 14 '08 #8
NeoPa
32,556 Expert Mod 16PB
Trevor, the easiest way to add [ CODE ] tags to your post is to select the code you want included, then click on the button which looks like a # in the post entry page.

Your code is nicely formatted with the different clauses on separate lines. This is good and makes it more readable. Another technique to remember when working with SQL is that the table name is only required when more than one table (data source) is used in the FROM clause of your SQL.
Expand|Select|Wrap|Line Numbers
  1. SELECT ReferredTo
  2. FROM ReferredToLU
  3. WHERE ((ReferredTo<>'N/A')
  4.   AND ([Status])<>'Lead'))
  5. ORDER BY ReferredTo;
Notice how much easier this is to read and digest.

Access often puts some quite naff SQL in its queries, so don't look to what it creates as a good format of SQL necessarily. It's very handy to use it to create the SQL for you though. Access also (quite incorrectly) uses double-quotes (") instead of single-quotes (') to denote string data. It will interpret single-quotes correctly though.

Hope all this helps.
Mar 14 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Miroslav I. | last post by:
------=_NextPart_000_0009_01C35A6F.9908B420 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Hallo suppose you have a table with great number of...
24
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
1
by: Rinee | last post by:
Hi, I have a database of a bunch of contractors who have signed a safety agreement with us, their contact info, their insurance info, etc. Each was assigned an ID number as the main key. Each...
3
by: athos | last post by:
Hi guys, please help. What I did is : Step1. create a Database named , it's default owner is Step2. create a User in Database named , which maps to the Login on this Database Server, it's a...
8
by: swsdam | last post by:
Thank you for even reading this... I have an xml doc that feeds into html. I am being passed the xml via asp.net. I have used xsl to create an html. Now I'm being asked to let the user omit which...
3
emandel
by: emandel | last post by:
I have a query which is giving me and This is a Union Query and therefor some records are repeated. In addition some households have differant members wusing the same e-mail. How do I make a...
1
by: ZAVILA | last post by:
This is the SQL code for starters. SELECT DISTINCTROW .CYCLE_DATE, .SERIES_NBR, .SERVICER_NBR, .SERVICER_NAME, .SERVICER_LOAN_NBR, .LOAN_NBR, .INTERNAL_LOAN_ID, .ARCC_LOAN_NBR, .LIEN_STATUS_CODE,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 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.