By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Count the data

P: 3
I have a table called program within it are several fields including:

id_program
id_student

how I want to get id_student based on highest id_program volumes of data

let say row in table:-

row 1 : id_program : 1, id_student :001,
row 2 : id_program : 2, id_student :001,
row 3 : id_program : 3, id_student :002,
row 4 : id_program : 4, id_student :001,
row 5 : id_program : 5, id_student :003.


query that i need is it will result like this :-
highest program : 001
Number program : 3
Apr 27 '12 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,370
I have no idea how you went from your sample data to your results.
Apr 27 '12 #2

P: 3
I want to get the most id_student create programs
Apr 28 '12 #3

Rabbit
Expert Mod 10K+
P: 12,370
Yes, you've already said that, I don't know what you mean by it.
Apr 28 '12 #4

P: 21
You can simply Use
Select Id_student as highest_program, Count(Id_student) as Number_program From Your table name
Apr 29 '12 #5

P: 92
This question belongs to SQL. Anyway, use GROUP BY and COUNT together

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(id_program) AS prog, id_program, id_student FROM YourTable GROUP BY id_student
Apr 30 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.