ing no of different rows by group by clause
Hi Friends,
I have a table like
name
MAD
LHR
MAD
LHR
AKL
AWL
AKL
LHR
I want the output as:
LHR 3
AKL 2
AWL 1
etc...
ie the no of entires sorted by their no of appearences.
I cannot do that by select name from tab_name group by name as it will not
g
Abhishek
>I want the output as:
>LHR 3
>AKL 2
>AWL 1...
>ie the no of entires sorted by their no of appearences.
SELECT
tbl.name AS Name,
COUNT( tbl.name) AS Count
FROM tbl
GROUP BY tbl.name
ORDER BY Count DESC;
PB
[EMAIL PROTECTED] wrote:
Hi Friends,
I have a table like
name
MAD
LHR
Hi Abishek,
I want the output as:
LHR 3
AKL 2
AWL 1
This should do it:
SELECT name, COUNT(*) as num
FROM tab_name
GROUP BY name
ORDER BY num DESC
Regards,
Jeremy
--
Jeremy Cole
MySQL Geek, Yahoo! Inc.
Desk: 408 349 5104
--
MySQL General Mailing List
For list archives: http://lists.mysql.c
Hi Friends,
I have a table like
name
MAD
LHR
MAD
LHR
AKL
AWL
AKL
LHR
I want the output as:
LHR 3
AKL 2
AWL 1
etc...
ie the no of entires sorted by their no of appearences.
I cannot do that by select name from tab_name group by name as it will not
give me the no of rows.
Pl. help me to find i
On May 19, 2005, at 12:51 AM, Dan Rossi wrote:
Hi there, I am having issues with this funny error message. I am
trying to do a sub query and then a group by clause on a date.
However i keep getting this annoying message for some reason.
Happens via terminal aswell as my sql gui. Here is the
Hi there, I am having issues with this funny error message. I am trying
to do a sub query and then a group by clause on a date. However i keep
getting this annoying message for some reason. Happens via terminal
aswell as my sql gui. Here is the query I am trying to do
select (select count
lcount, itemname from viewvisitor where ownerid =
2 GROUP BY concat( app, itemid ) ORDER BY totalcount;
Rich Carr wrote:
>Is there a way to set which rows values are used by the GROUP BY clause for
>the fields that are not in the GROUP BY clause?
>
>In this following select statement the
BY clause for the
fields that are not in the GROUP BY clause?
In this following select statement the group by and order work but the value of the lastviewtime field is not the value of the most recent datetime row. Is there any way to modify the select statement so that the returned lastviewtime
|
>+--++--+
>
>or GROUP_ROW(cols,sortby=)
>
>-- More sillyness
>SELECT id, group_row(child_id,type,sortby=rand())
>FROM chi2 GROUP BY id;
>
>Just an idea.
>
>Dan.
>
>On Mon, 11 Apr 2005, Rich Carr wrote:
>
>>Is there a way to set which ro
t;+--++--+
>| 1 | 1 | 0 |
>| 5 | 2 | 2 |
>+--++--+
>
>or GROUP_ROW(cols,sortby=)
>
>-- More sillyness
>SELECT id, group_row(child_id,type,sortby=rand())
>FROM chi2 GROUP BY id;
>
>Just an idea.
>
>Dan.
>
>On Mon, 11 Apr
id, group_row(child_id,type,sortby=rand())
FROM chi2 GROUP BY id;
Just an idea.
Dan.
On Mon, 11 Apr 2005, Rich Carr wrote:
>Is there a way to set which rows values are used by the GROUP BY clause
>for the fields that are not in the GROUP BY clause?
> In this following select statement
Is there a way to set which rows values are used by the GROUP BY clause for the
fields that are not in the GROUP BY clause?
In this following select statement the group by and order work but the value of
the lastviewtime field is not the value of the most recent datetime row. Is
there any
On Friday, February 25, 2005 15:05, Asad Habib wrote:
> I am trying to use GROUP BY with a field of type text that is set to
> NOT NULL by default. However, in practice this field does not always
> contain a string for every record and defaults to the empty string in
> this case. When I try to us
I am trying to use GROUP BY with a field of type text that is set to NOT
NULL by default. However, in practice this field does not always contain a
string for every record and defaults to the empty string in this case.
When I try to use GROUP BY with this field in a SELECT statement, only 1
record
From: Greg Owen [mailto:[EMAIL PROTECTED]
> I'm trying to build a query to show counts of specific
> columns by value.
> There's probably a simple way to do this that I don't know
> about, and if you could just point me to the function or part
> of the manual to research before you start lau
On Mon, 5 Jan 2004, Greg Owen wrote:
> I tried (you can laugh here) to do it this way, but failed miserably:
>
> mysql> select class,count(questnum),count(difficulty='0'),
>count(difficulty='1'),count(difficulty='2'),
>count(in_use='0'),count(in_use='1') from Questions
>group by class;
I'm trying to build a query to show counts of specific columns by value.
There's probably a simple way to do this that I don't know about, and
if you could just point me to the function or part of the manual to
research before you start laughing, I'd greatly appreciate it.
Given the following
> Is there a way to use a string concatenating function in connection with a
> GROUP BY clause? I mean, for a one-to-many relation (like firm-stockholders
> relation), to "catch" a structure like:
>
> firm | stocholders
>
> f_1 | s_1; s_2
Is there a way to use a string concatenating function in connection with a
GROUP BY clause? I mean, for a one-to-many relation (like firm-stockholders
relation), to "catch" a structure like:
firm | stocholders
f_1 | s_1; s_2; s_3
f_2 | s_4; s_5
f_3 | s_6
inste
That can't be the output of the query.
The fourth column would me titled 'soma'
There is no seperator bar between the data for sw_or_local and soma on
the data lines.
Fabio Bernardo wrote:
hi there
I wrote this querie :
select pop, prot, sw_or_local, sum(qtd_porta) as soma from clientes where
s
Fabio Bernardo wrote:
select pop, prot, sw_or_local, sum(qtd_porta) as soma from clientes where
status<>'C' group by pop,prot,sw_or_local
And I have this result :
+++-++
| pop| prot | sw_or_local | sum |
+++-++
|B
hi there
I wrote this querie :
select pop, prot, sw_or_local, sum(qtd_porta) as soma from clientes where
status<>'C' group by pop,prot,sw_or_local
And I have this result :
+++-++
| pop| prot | sw_or_local | sum |
+++-+---
: i have one table with 4 fields
(nik,name,child_name,child_number)
i wan to query that the result will be like this
+--+---++++ +
| nik | name | child1 | child2 | child3 | child4 |
+--+---++++ +
| 1 | pai | mai | NUL
ruary 16, 2002 3:42 PM
Subject: urgent : Problem in Group by clause
hi all,
i have a problem in mysql query...
lemme state the scenario...
i have a table 'UploadDetails' in which i am storing
data regd files...
the fields are:
FileName, Title, Designer, UploadedBy, SubmittedDate
i
hi all,
i have a problem in mysql query...
lemme state the scenario...
i have a table 'UploadDetails' in which i am storing
data regd files...
the fields are:
FileName, Title, Designer, UploadedBy, SubmittedDate
i want to get details about whose files are designed
by who..etc...
that is i need
hi all,
i have a problem in mysql query...
lemme state the scenario...
i have a table 'UploadDetails' in which i am storing
data regd files...
the fields are:
FileName, Title, Designer, UploadedBy, SubmittedDate
i want to get details about whose files are designed
by who..etc...
that is i need
Serge,
> Is it possible in mySQL to GROUP BY months on a date field?
> For example:
> SELECT invDate,prdCategory,sum(prdPrice)
> GROUP BY left(invDate,6),prdCategory
> If invDate is in the format 20020202
> then group by the first 6 characters
> would return the total of sales
> by product catego
Is it possible in mySQL to GROUP BY months on a date field?
For example:
SELECT invDate,prdCategory,sum(prdPrice)
GROUP BY left(invDate,6),prdCategory
If invDate is in the format 20020202
then group by the first 6 characters
would return the total of sales
by product category and by month.
I
ng up the ordering?
Steve Meyers
> -Original Message-
> From: Sommai Fongnamthip [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 19, 2001 3:19 AM
> To: [EMAIL PROTECTED]
> Subject: group by clause
>
>
> Hi,
> did someone tell me why group by clause
Hi,
did someone tell me why group by clause not work? I'd like to group
volume of order from my customer at the same price and my supplier. here
is my code
Select custid, symbol, sum(volume) as sumvol, price, mktid, supplier,
supplierflag
From confirm
You might want to add an ORDER BY clause.
Sommai Fongnamthip wrote:
> Hi,
> did someone tell me why group by clause not work? I'd like to group
> volume of order from my customer at the same price and my supplier.
> here is my code
>
> Select custid, symbol
Hi,
did someone tell me why group by clause not work? I'd like to group
volume of order from my customer at the same price and my supplier. here
is my code
Select custid, symbol, sum(volume) as sumvol, price, mktid, supplier,
supplierflag
From confirm
Hi
I am using windows2000 server and MYSQL ver3.23.41-win and Active Server
Pages to retreive MYSQL result set to my webpage, It is retreiving well if
there is only one row in the table( It is not reaching EOF immediately),
but if there is more then one row (in group by result) then immediately
r
33 matches
Mail list logo