Sql queary

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

Sql queary

Post by myharshdesigner »

i want to use Group by
but i also wan to display all the rows which is presented in the database.
And at the end of a group i want to display Some of all The rows in a group.

like i have 10 rows in a database and there is a three group

in 1st group there is 5 rows.

in 2nd group there is 2 rows.

and

in 3rd group there is 3 rows.

so i just want to display the sum of all amount in a group.

so pl tell me what query i suppose to use for getting what i want .

waiting for some help
with example

thanks
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Do you mean something like...

Code: Select all

SELECT mygroup,count(mygroup) FROM tablename GROUP BY mygroup;
(where mygroup is the column you are grouping on).
Post Reply