extracting data with multiple conditions

S

sneha bhawalkar

hi

i am writting one query in which i want two feilds with two different
where conditions
(i.e select sum(amount) from T1 where "condition1"
&
select sum(amount) from T1 where "condition2"
)
i want both of these sum in one select statement..
how to write it??
 
K

Kernow Girl

Hi Sneha - the easy way is - in the Query go to the field(s) you want to
Sum. Click on the Totals button on the toolbar. This adds a Totals line. On
the field(s) you want to sum change it from Group By to Sum. Then, on the
Criteria line enter what you want to select by. If this is variable, put a
variable on each Criteria line. Do this by putting something in square
brackets [] to indicate what to enter, such as [enter date] and [enter date
1]. If you are selecting by the same variable, put the same thing on each
line. Yhew - hope this helps!
 
D

Duane Hookom

Does this query include T1 in its select or is T1 unrelated to your main
query? Do you want to add numeric values (+) or concatenate as your example
suggests (&)?

A WAG is to use something like:
(SELECT Sum(Amount) FROM T1 WHERE Gender="F") + (SELECT Sum(Amount) FROM T1
WHERE HireDate >#1/1/2005#) as TotalBoth
 
S

sneha.bhawalkar

but if we use + sign between two queries it shows addition of both
amount i want to display both amount in two different columns..
 
D

Duane Hookom

You stated "sum in one select statement" which I took to mean a single
value. What's your issue with using two subqueries? Can you describe your
tables and desired results?
 
S

sneha.bhawalkar

table T1 have columns date and amount
now i want sum of amount from date 11-Mar-2006 to 17-Mar-2006 as one
column and sum of amount from 18-Mar-2006 to 24-Mar-2006 as another
column.
 
D

Duane Hookom

Do you have only one table in the query? Do you ever want to change the date
ranges or are these dates etched in stone?
 
S

sneha.bhawalkar

I have two tables.Date range i am taking from different table.Date
field is common in both table.
 
D

Duane Hookom

Please provide your actual table and field names. It is very difficult to
help you when you only provide small bits of information about your current
situation and requirements. I can't justify the time this is taking to help
you when it seems you don't or won't provide complete information. I don't
care for making guesses.

Please provide more information or hope that someone else will assist you
with this question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top