SQL: "group by" should work case sensitive

B

Bernd Muent

Hi together,
I've got an ACCESS database on which I work with SQL statements:
It 's german but I think this does not matter for my problem.
FRAGE ANTWORT BEREICH
3*3 9 MATHE
4+2 6 Mathe
2+1 3 Mathe
4/4 1 MATHE
Haus House ENGLISCH
Hauptwort Nomen Deutsch
VERB Zeitwort DEUTSCH

So there is "MATHE" and "Mathe" in "Bereich"(=topic)

To get all the questions and answers of the topic "MATHE" (not "Mathe"!)
I use this SQL statement:
select frage,antwort from aufgaben where StrComp(bereich,'MATHE',0)=0

No I like to know how which topics are in the table and how many
questions per topic:
SELECT bereich,count(bereich) as anzahl from aufgaben group by bereich
order by bereich desc
returns the following result:
FACH ANZAHL
Deutsch 2
ENGLISCH 1
MATHE 4

So, unfortunately, this "group by" is not case sensitive :-(

Has anybody an idea how to extend this "group by" so that it will do
what I want?

Thank you for tips, Bernd
 
K

Ken Snell [MVP]

Try including the comparison as a calculated field:

SELECT bereich,count(bereich), StrComp(bereich, UCase(bereich), 0) as anzahl
from aufgaben group by bereich, StrComp(bereich, UCase(bereich), 0) order by
bereich desc;
 
B

Bernd Muent

Ken said:
SELECT bereich,count(bereich), StrComp(bereich, UCase(bereich), 0) as anzahl
from aufgaben group by bereich, StrComp(bereich, UCase(bereich), 0) order by
bereich desc;

Thank you. That is exactly what I was looking for, Bernd
 

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