Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Query Question 2

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
Hi, I have a Query, in which I wish to Sum all the rows in a table that have an answerType of 1, and then, from that I wish to also calculate the proportion of those that answered Question1 as "Yes", and that who answered "No". I can see that No is just Total - Yes, so at this stage Im not too bothered about that.

At present I am doing
Code:
Count(History.PageID) AS Tota1Q1Answered, Count(History.Response) AS TotalYes
Group By ..
HAVING ( ( (History.Response)="YES"));
 
Code:
select Count(History.PageID) AS Tota1Q1Answered
     , Sum(Iif(History.Response='YES',1,0)) AS TotalYes
  from ...
Group By ...

r937.com | rudy.ca
 
Thanks, that gets me started.

I haev 2 more problems, but Im trying to fix them before I come back here.
(Ive failed at the first :-/)

The above sql in my query then returns 2 rows
1 Row has the total of those that answered Yes
The other Row has all those that answered no

Is there any way I can modify the above, so that I get a single row. All Im interested in is getting the total number of records in the table where Q1 was answered, The Total that answered Yes, and the total that answered no, all in one line.

K
 
Code:
SELECT Count(History.PageID) AS Tota1Q1Answered
     , Sum(Iif(History.Response='YES',1,0)) AS TotalYes
     , Sum(Iif(History.Response='YES',0,1)) AS TotalNo
without any Group By clause
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top