jonnycattt
Registered User.
- Local time
- Today, 10:53
- Joined
- Sep 29, 2001
- Messages
- 20
I'm working with a DB I didn't design and have a small problem. I need to group aggregate results by a column called "Issue". Issue is a date (formatted as "Jan 1", for example), but the field is typed as a text field.
Here's my code:
SELECT [2002 ji papers].Issue, count([2002 ji papers].Logic) AS TotalArticles
FROM [2002 ji papers]
WHERE [2002 ji papers].Issue IN (SELECT Issues FROM ShowMonths)
GROUP BY Issue
In my Where clause, if I type the following it works just fine: "Jan 1", "Jan 15"
It returns my aggregate data grouped by Jan 1 and Jan 15.
My subquery is taking a list of values that are in one field in a column called "Issues". In this field are stored a comma delimited list of strings.
This subquery (above) returns the exact same thing as my hardcoded values ("Jan 1", "Jan 15"), but when I use the subquery instead of the hardcoded values, the query returns nothing.
So I have two questions: 1, is there a better way to design this query. Although I can't change anything in existing tables, I can create new tables. So I created the ShowMonths table to store the values of the issues whose aggregate value I need. this field is updated through other processes (web page).
2) If I'm designing this thing correctly, how do I get this subquery to work?
Thanks in advance for any help
Marc
Here's my code:
SELECT [2002 ji papers].Issue, count([2002 ji papers].Logic) AS TotalArticles
FROM [2002 ji papers]
WHERE [2002 ji papers].Issue IN (SELECT Issues FROM ShowMonths)
GROUP BY Issue
In my Where clause, if I type the following it works just fine: "Jan 1", "Jan 15"
It returns my aggregate data grouped by Jan 1 and Jan 15.
My subquery is taking a list of values that are in one field in a column called "Issues". In this field are stored a comma delimited list of strings.
This subquery (above) returns the exact same thing as my hardcoded values ("Jan 1", "Jan 15"), but when I use the subquery instead of the hardcoded values, the query returns nothing.
So I have two questions: 1, is there a better way to design this query. Although I can't change anything in existing tables, I can create new tables. So I created the ShowMonths table to store the values of the issues whose aggregate value I need. this field is updated through other processes (web page).
2) If I'm designing this thing correctly, how do I get this subquery to work?
Thanks in advance for any help
Marc