PC Review


Reply
Thread Tools Rate Thread

Complex (for me) calculations on database

 
 
trettr
Guest
Posts: n/a
 
      29th Aug 2003
Hi,
I need help to solve this problem.
I design a questionnarie and my client ask to a report of the results, much of
the answer are precompiled so I know the possibile value. For examples at
question A, and B the possible answer are YES or NO.

My problem is the I have to create a table in which I specify how much people
answers YES and NO at question A, and how much people answers YES and NO at
question B, and so on.

I'm able to recover only one value in a sql query.
<
Select count(A)
from MYtable
where A='YES'
>


So how can I recover all the sums for given values in every column?

Thank You very much
 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      29th Aug 2003
On Fri, 29 Aug 2003 14:03:35 GMT, "trettr" <(E-Mail Removed)> wrote:

>Hi,
>I need help to solve this problem.
>I design a questionnarie and my client ask to a report of the results, much of
>the answer are precompiled so I know the possibile value. For examples at
>question A, and B the possible answer are YES or NO.
>
>My problem is the I have to create a table in which I specify how much people
>answers YES and NO at question A, and how much people answers YES and NO at
>question B, and so on.
>
>I'm able to recover only one value in a sql query.
><
>Select count(A)
>from MYtable
>where A='YES'


Try using the IIF function to generate a number that you can sum:

SELECT Sum(IIF([A] = 'YES', 1, 0)) AS YesOnA, Sum(IIF([A] = 'NO')) AS
NoOnA, ...


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
trettr
Guest
Posts: n/a
 
      1st Sep 2003


> Try using the IIF function to generate a number that you can sum:
>

Sorry why the first part
>Sum(IIF([A] = 'YES'

there is after the above condition
>, 1, 0)

while in the second part
>Sum(IIF([A] = 'NO'

there isn't the same string?
I suspect it's a silly question but I know few about sql...

Thank you


> SELECT Sum(IIF([A] = 'YES', 1, 0)) AS YesOnA, Sum(IIF([A] = 'NO')) AS
> NoOnA, ...
>
>
> John W. Vinson[MVP]
> Come for live chats every Tuesday and Thursday
> http://go.compuserve.com/msdevapps?loc=us&access=public
>

 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      2nd Sep 2003
On Sun, 31 Aug 2003 23:18:20 GMT, "trettr" <(E-Mail Removed)> wrote:

>
>
>> Try using the IIF function to generate a number that you can sum:
>>

>Sorry why the first part
>>Sum(IIF([A] = 'YES'

>there is after the above condition
>>, 1, 0)

>while in the second part
>>Sum(IIF([A] = 'NO'

>there isn't the same string?


Because I was typing hastily and made a mistake. There should be.

The IIF() function has three arguments: a logical expression (i.e.
[A]='Yes'); a value to return if the expression is True; and a value
to return if it is False.

Sorry for the confusing and wrong answer - but it seems you figured
out the right one!


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table with complex calculations Rick Microsoft Excel Worksheet Functions 3 6th Jan 2008 07:08 AM
RE: Iterations of complex calculations =?Utf-8?B?c2IxOTIwYWxr?= Microsoft Excel Misc 0 25th Feb 2007 06:01 AM
Re: Iterations of complex calculations Mike Middleton Microsoft Excel Misc 0 10th Jan 2007 07:43 PM
complex calculations juliadesi Microsoft Excel Misc 6 17th Mar 2006 01:14 PM
*Complex query/calculations =?Utf-8?B?Sk1vcnJlbGw=?= Microsoft Access 1 1st Mar 2004 03:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:16 PM.