Page 1 of 1
[solved]SQL query-Counting frequency in each route
Posted: Tue Apr 08, 2008 5:29 pm
by silverme
I'm trying to set up an query in MS Access.
table tbDELIVERY has field ORIGIN and DESTINATION (both in char)
ORIGIN DESTINATION
1 A
1 B
1 B
1 B
1 A
1 A
2 A
2 B
1 B
2 B
1 A
2 A
1 C
--------------------------------------------
How do I set up a query in SQL that counts the frequency of each route (1A, 1B, 1C, 2A,2B)?
1A --> 4
1B --> 4
1C --> 1
2A --> 2
2B --> 2
Thanks a lot!
Re: SQL query? Counting frequency in each route
Posted: Tue Apr 08, 2008 6:40 pm
by Christopher
Something like:
Code: Select all
SELECT ORIGIN, DESTINATION, SUM(ORIGIN) FROM tbDELIVERY GROUP BY ORIGIN, DESTINATION;
Re: SQL query? Counting frequency in each route
Posted: Wed Apr 09, 2008 4:51 am
by EverLearning
SUM(origin) wont work. You need COUNT
Code: Select all
SELECT ORIGIN, DESTINATION, COUNT(ORIGIN) FROM tbDELIVERY GROUP BY ORIGIN, DESTINATION;
Re: [Solved]SQL query? Counting frequency in each route
Posted: Wed Apr 09, 2008 12:50 pm
by silverme
Thanks guys
Re: [Solved]SQL query? Counting frequency in each route
Posted: Wed Apr 09, 2008 10:06 pm
by shamuraq
now my problem is almost like tt. let me just paint a scenario. in mysql i have a table with test-dates as the rows(y-axis) and the classes i am teaching as the columns(x-Axis). The data in the table are scores from my students from all these classes. how do i "count" the total number of students(classes combined) lets say scoring 50%? really appreciate any help to shed some light in this matter.
the difference with the previous problem is tt it is only focused on values within one column whereas mine is COUNTING number of similar result from multiple columns.