Group By Problem

Group By Problem

am 08.02.2011 12:01:39 von Adarsh Sharma

--------------000900030208090400040904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dear all,

I stuck around one more simple problem today.

I have a table named *event_loc* having below data : ( It has many
columns but I show you main columns that I needed )

_*Tables Data :-*_

*source_id event_text*

1233 meet
1233 meet
1345 ends
1345 ends
1111 performs
13456 Minister
1233 Argentina
1233 meet
1345 ends
1555 is

As described above there are more than 100000 rows and I want my output as :

_*Output Needed :-*_

*source_id event_text Count*

1233 meet 3
1233 Argentina 1
1345 ends 3
1111 performs 1
13456 Minister 1


I tried the below query :

*select source_id ,event_text,count(*) from event_loc group by
source_id,obj_text ;*

But displays only unique record_id rows but I want as mentioned output.

Failed to achieve the mentioned output.


Thanks & Regards

Adarsh Sharma

--------------000900030208090400040904--

RE: Group By Problem

am 08.02.2011 14:57:28 von Peter He

--_0bc6ca09-fbcf-4a84-953c-33f840b7f04b_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


You need to group by event_text=2C not obj_text:
=20
select source_id =2Cevent_text=2Ccount(*) from event_loc=20
group by source_id=2Cevent_text=3B
=20
=20
> Date: Tue=2C 8 Feb 2011 16:31:39 +0530
> From: adarsh.sharma@orkash.com
> To: mysql@lists.mysql.com
> Subject: Group By Problem
>=20
> Dear all=2C
>=20
> I stuck around one more simple problem today.
>=20
> I have a table named *event_loc* having below data : ( It has many=20
> columns but I show you main columns that I needed )
>=20
> _*Tables Data :-*_
>=20
> *source_id event_text*
>=20
> 1233 meet
> 1233 meet
> 1345 ends
> 1345 ends
> 1111 performs
> 13456 Minister
> 1233 Argentina
> 1233 meet
> 1345 ends
> 1555 is
>=20
> As described above there are more than 100000 rows and I want my output a=
s :
>=20
> _*Output Needed :-*_
>=20
> *source_id event_text Count*
>=20
> 1233 meet 3
> 1233 Argentina 1
> 1345 ends 3
> 1111 performs 1
> 13456 Minister 1
>=20
>=20
> I tried the below query :
>=20
> *select source_id =2Cevent_text=2Ccount(*) from event_loc group by=20
> source_id=2Cobj_text =3B*
>=20
> But displays only unique record_id rows but I want as mentioned output.
>=20
> Failed to achieve the mentioned output.
>=20
>=20
> Thanks & Regards
>=20
> Adarsh Sharma
=

--_0bc6ca09-fbcf-4a84-953c-33f840b7f04b_--