Need help for query

S

sadat

Hi there,
I have a table in the following format:

Month Category Value
Jan A 1
Feb B 5
Mar A 8
Apr B 4
May A 6
I want to sum up the value category wise in a single query. What I did is:
SELECT Table.Month, Table.[Value], Table.[Value]
FROM

WHERE (((Table.Category)="A") AND ((Table.Category)="B"))
GROUP BY Table.Month, Table.[Value], Table.[Value];
But the table provides null value. Why is it happening? I am a beginner. So
need an elaborate explanation.

Thanking you in advance,
 
A

Allen Browne

If there is any record in the table where Category = "B", then that record
cannot possibly have the Category = "A" as well. Therefore the requirement:
(((Table.Category)="A") AND ((Table.Category)="B"))
cannot be met by any record.

Try:
(((Table.Category)="A") OR ((Table.Category)="B"))
 
S

sadat

Thank you Allen for your quick reply. But the problem is then the result
shows same value for all the columns. Please be informed that this query will
collect result from a single column and show in two different column with
different criteria.

A little more help will be useful.

Thanks and regards,
Sadat Mainuddin

Allen Browne said:
If there is any record in the table where Category = "B", then that record
cannot possibly have the Category = "A" as well. Therefore the requirement:
(((Table.Category)="A") AND ((Table.Category)="B"))
cannot be met by any record.

Try:
(((Table.Category)="A") OR ((Table.Category)="B"))

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

sadat said:
Hi there,
I have a table in the following format:

Month Category Value
Jan A 1
Feb B 5
Mar A 8
Apr B 4
May A 6
I want to sum up the value category wise in a single query. What I did is:
SELECT Table.Month, Table.[Value], Table.[Value]
FROM

WHERE (((Table.Category)="A") AND ((Table.Category)="B"))
GROUP BY Table.Month, Table.[Value], Table.[Value];
But the table provides null value. Why is it happening? I am a beginner.
So
need an elaborate explanation.

Thanking you in advance,
 
A

Allen Browne

I didn't follow that.

The example you posted shows 3 columns: a month, category, and value.

The query statement you posted shows the month, and then the same value
twice.

Perhaps you are trying to create a crosstab query, were:
- month is the Row Heading
- Category is the Column Heading
- Value is the value?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

sadat said:
Thank you Allen for your quick reply. But the problem is then the result
shows same value for all the columns. Please be informed that this query
will
collect result from a single column and show in two different column with
different criteria.

A little more help will be useful.

Thanks and regards,
Sadat Mainuddin

Allen Browne said:
If there is any record in the table where Category = "B", then that
record
cannot possibly have the Category = "A" as well. Therefore the
requirement:
(((Table.Category)="A") AND ((Table.Category)="B"))
cannot be met by any record.

Try:
(((Table.Category)="A") OR ((Table.Category)="B"))

sadat said:
Hi there,
I have a table in the following format:

Month Category Value
Jan A 1
Feb B 5
Mar A 8
Apr B 4
May A 6
I want to sum up the value category wise in a single query. What I did
is:
SELECT Table.Month, Table.[Value], Table.[Value]
FROM

WHERE (((Table.Category)="A") AND ((Table.Category)="B"))
GROUP BY Table.Month, Table.[Value], Table.[Value];
But the table provides null value. Why is it happening? I am a
beginner.
So
need an elaborate explanation.
 

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

Similar Threads


Top