473,378 Members | 1,384 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,378 software developers and data experts.

How to do a query on data type memo?

I keep getting a message," syntax in your sub query is incorrect". For the following code:

SELECT IIf(IsNull([Answer]);"No";"Yes") AS [Answered?]; Count(IIf(IsNull([Answer]);"No";"Yes")) AS Qtd
FROM Motivos
GROUP BY IIf(IsNull([Answer]);"No";"Yes");

My memo data type is "answer". I need to know how many users answered in the memo(answer)data type, and how many users didn't. And I need to also show the users who wrote something on the memo data type.
Feb 6 '11 #1
2 2540
Stewart Ross
2,545 Expert Mod 2GB
There is a repeated error in your IIF statement, where you are separating the arguments with semi-colons instead commas:

Expand|Select|Wrap|Line Numbers
  1.                                 v    v 
  2. incorrect - IIf(IsNull([Answer]);"No";"Yes")
  3.                                 ^    ^
  4.  
  5. correct   - IIf(IsNull([Answer]),"No","Yes")
  6.  
You are also repeating the same problem within the SQL statement itself, where you are using the semi-colon to separate fields instead of the comma.

Your first IIF groups the results into whether or not an answer has been provided. Accordingly there will be two rows returned, one in which the calculated field you have called [Answered?] will take the value "Yes", and the other "No". Beside it you will then have a count of the number of rows.

I can simplfy the SQL for this a little and use the SQL 'IS NULL' statement in place of the IsNUll() function as follows:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.   IIf([Answer] IS NULL, "No", "Yes") AS [Answered?], 
  3.   Count([Answer]) AS [No of Answers]
  4. FROM 
  5.   Motivos
  6. GROUP BY 
  7.   IIf([Answer] IS NULL, "No", "Yes");
This will not give you an overall total because of the "yes"/"no" grouping. To get all of what you want in one row you could use something like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.   Count([Answer]) AS [Total Rows], 
  3.   Sum(IIf([Answer] Is Null,0,1)) AS [Answered], 
  4.   Sum(IIf([Answer] Is Null,1,0)) AS [Not Answered]
  5. FROM Motivos;
-Stewart
Feb 6 '11 #2
Wow! Your good!
Feb 6 '11 #3

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

Similar topics

6
by: mbev | last post by:
Is it possible to add more than 65,000 characters in a field in Microsoft Access 2003? With the data type "MEMO" only let me add 65,000 characters. Thanks in advance.
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
1
by: Igor Barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
0
by: Dilruba | last post by:
I want retrieve data from Ms Access 2000 database by using ASP and data type memo and after that i want e-mail that data automatically
16
by: The Frog | last post by:
Hi Everyone, I have a small problem that doesnt seem to make any sense. I am using Access 97, and have a query that selects data from a text field, converts it to type Lng. This seems to work...
2
by: eyoung1 | last post by:
this works sSQL = "SELECT *" & _ " FROM Expenses2008" & _ " WHERE Amount Like '%" & Request.Form("searchItem") & "%'" set rs = Connect.Execute(sSQL) however if I enter an amount of 99 it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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 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.