Group By Problem

--------------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--
Adarsh Sharma [ Di, 08 Februar 2011 12:01 ] [ ID #2054776 ]

RE: Group By Problem

--_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:

select source_id =2Cevent_text=2Ccount(*) from event_loc
group by source_id=2Cevent_text=3B


> Date: Tue=2C 8 Feb 2011 16:31:39 +0530
> From: adarsh.sharma [at] orkash.com
> To: mysql [at] lists.mysql.com
> Subject: Group By Problem
>
> Dear all=2C
>
> 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 a=
s :
>
> _*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 =2Cevent_text=2Ccount(*) from event_loc group by
> source_id=2Cobj_text =3B*
>
> But displays only unique record_id rows but I want as mentioned output.
>
> Failed to achieve the mentioned output.
>
>
> Thanks & Regards
>
> Adarsh Sharma
=

--_0bc6ca09-fbcf-4a84-953c-33f840b7f04b_--
Peter He [ Di, 08 Februar 2011 14:57 ] [ ID #2054777 ]
Datenbanken » gmane.comp.db.mysql.general » Group By Problem

Vorheriges Thema: Replacing MS SQL with MySql
Nächstes Thema: Replication Error on Slave