On 2011-1-16 20:22, Jørn Dahl-Stamnes wrote:
Hello,
I got a table that store information about which photo-albums that a client is
viewing. I want to get the N last visited albums and use the query:
mysql select album_id, updated_at, created_at from album_stats order by
updated_at desc limit
On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote:
mysql select album_id, updated_at, created_at from album_stats group by
album_id order by updated_at desc limit 8;
I believe that your problem is that the group by happens before the
order by. Since you're grouping, the updated_at column is not
On Monday 17 January 2011 09:53, Steve Meyers wrote:
On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote:
mysql select album_id, updated_at, created_at from album_stats group by
album_id order by updated_at desc limit 8;
I believe that your problem is that the group by happens before the
order
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
He meant the execution order, please use the agregation function as
suggested.
On 11-01-17 05:03, Jørn Dahl-Stamnes wrote:
On Monday 17 January 2011 09:53, Steve Meyers wrote:
On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote:
mysql select album_id,
Hello,
I got a table that store information about which photo-albums that a client is
viewing. I want to get the N last visited albums and use the query:
mysql select album_id, updated_at, created_at from album_stats order by
updated_at desc limit 8;
I'm having trouble formulating a query to gather the following data. I can
do this via a script, but now it is more or less just bothering me if there
is an easy/efficient way to gather the following data from a single query.
Example Tables
Products
Type Cost Vendor_id
Scott,
I would like to obtain the least cost of each product type and its
associated vendor.
See Within-group aggregates at
http://www.artfulsoftware.com/infotree/queries.php.
PB
-
On 7/14/2010 9:25 AM, Scott Mullen wrote:
I'm having trouble formulating a query to gather the
On Wednesday, July 14, 2010 09:25:22 am Scott Mullen wrote:
I'm having trouble formulating a query to gather the following data. I can
do this via a script, but now it is more or less just bothering me if there
is an easy/efficient way to gather the following data from a single query.
Date: Wed, 14 Jul 2010 10:25:22 -0400
Subject: Select w/ group by question
From: smulle...@gmail.com
To: mysql@lists.mysql.com
I'm having trouble formulating a query to gather the following data. I can
do this via a script, but now it is more or less just bothering me
Peter
Thanks for the link. I've never run across this page before, but it has
tons of useful informationas well as several answers on how to implement
what I was trying to do.
Ended up going with a solution similar to this example (from the page you
referenced):
SELECT
item,
SUBSTR(
It must be too late in the week…
Suppose table Cust has one field, CustID. Suppose table Notes has four fields:
NoteID (unique), CustID, NoteTime, and NoteText.
A customer can have zero or more notes. Now here’s the seemingly simple problem
that I’m trying to solve: I want to find the
Jerry,
I want to find the newest note (if any) for each customer.
See Within-group aggregates at
http://www.artfulsoftware.com/infotree/queries.php
http://www.artfulsoftware.com/queries.php
PB
-
Jerry Schwartz wrote:
It must be too late in the week...
Suppose table Cust has
, September 25, 2009 1:28 PM
To: mysql@lists.mysql.com
Subject: Stupid GROUP BY question
It must be too late in the week…
Suppose table Cust has one field, CustID. Suppose table Notes has four fields:
NoteID (unique), CustID, NoteTime, and NoteText.
A customer can have zero or more notes. Now here’s
but not in the group by.
The question is, is there any way to modify this query so that it would
return the team having the most entries?
Theoretical what I would like:
| cpid | sum(score) | team |
+---++---+
| a |600 | team1
it is team1,
and only 1 with team2 but the original query gives team2 and rightly so as
it just uses the first row in mysql's slightly illegal (but useful!) use of
allowing other columns in the query but not in the group by.
The question is, is there any way to modify this query so that it would
other columns in the query but not in the group by.
The question is, is there any way to modify this query so that it would
return the team having the most entries?
Theoretical what I would like:
| cpid | sum(score) | team
On 11/10/06, [EMAIL PROTECTED] wrote:
Hello everybody
Can you explain me please how to get the entire row where ID is maximum per
given status_id
Mysql 4.0.xx
Have you checked the manual? There is an entire page specifically
about the group-wise maximum.
Jochem
--
MySQL General Mailing List
How about
select ID, X, Y, Z from USERS order by ID desc limit 1
Tim
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, November 10, 2006 5:47 PM
To: mysql@lists.mysql.com
Subject: MAX() and GROUP BY question
Hello everybody
Can you explain me please
optimised solution
Thanks a lot
- Original Message
From: Tim Lucia [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Sent: Saturday, November 11, 2006 3:56:49 PM
Subject: RE: MAX() and GROUP BY question
How about
select ID, X, Y, Z from USERS order by ID desc limit 1
Tim
-Original Message
Hello everybody
Can you explain me please how to get the entire row where ID is maximum per
given status_id
Mysql 4.0.xx
for example:
id status_idnamedate
6 3 name0 date0
5 1 name1 date1
7 4 name3 date3
10 3 name2
:02 AM
Subject: Re: Group By question
Chris,
I would like to query all rows that have more
than one person with the same email address.
select id,count(emailaddr) as howmany
from tbl t1 join tbl t2 using(emailaddr)
group by id
having howmany1;
PB
-
Chris W wrote
select * from t where emailaddress in
(select emailaddress from t group by emailaddress having count(*) 1)
order by emailaddress;
Thanks,
Michael
-Original Message-
From: [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Sent: Wed, 30 Aug 2006 5:17 PM
Subject: Group By question
I have
I have a table of people with one of the fields being the email
address. I would like to query all rows that have more than one person
with the same email address. For example if the data were like this...
A [EMAIL PROTECTED]
B [EMAIL PROTECTED]
C [EMAIL PROTECTED]
D [EMAIL PROTECTED]
E
Chris,
I would like to query all rows that have more
than one person with the same email address.
select id,count(emailaddr) as howmany
from tbl t1 join tbl t2 using(emailaddr)
group by id
having howmany1;
PB
-
Chris W wrote:
I have a
table of people with one of the fields being
Sorry about the re-post, all!
Hello all,
I just inherited an application that has 2 tables under consideration, events
and attribute_master. They are linked on (events.eventID =
attribute_master.id AND attribute_master.tableis = 'events'). In other words,
attribute_master.id is kinda like a
In article [EMAIL PROTECTED],
Fan, Wellington [EMAIL PROTECTED] writes:
Hello Listfolk,
I have a table with a 'category_fk' column and a 'status' column. 'Status'
has but a tiny handful of known values, kinda like an enum.
I'd like to form a query that would give me results like:
Perfect! Thank you.
-Original Message-
From: Harald Fuchs [mailto:[EMAIL PROTECTED]
Subject: Re: Group By Question
SELECT category_fk,
sum(case status when 1 then 1 else 0 end) AS 'status=1',
sum(case status when 2 then 1 else 0 end) AS 'status=2',
sum(case
Hello Listfolk,
I have a table with a 'category_fk' column and a 'status' column. 'Status'
has but a tiny handful of known values, kinda like an enum.
I'd like to form a query that would give me results like:
category_fk | status=1 | status=2 | status=3 |
Hi,
I'm using MySQL 4.0.18 on Win2k Server. I have a table similar to the
following:
col1col2col3
A 1 this
A 2 is
A 3 a
B 1 test
B 2 table
What I would like to get with one query is the following result:
Without using a subquery, you have to do it in two steps. First you need
to collect the MAX(col2) values for each col1 value:
CREATE TEMPORARY TABLE tmpMaxes
SELECT col1, max(col2)
from test_table
GROUP BY col1
Then you want to get the rows where the col2 value is the maximum for each
col1
* Bengt Lindholm
I have a table where I need to group the content on a timestamp. Any
record that is less than say 5 minutes from any other record needs to
be grouped with that other record.
ID timestamp
1 2004-02-02 12:00:00
2 2004-02-02 12:00:05
3 2004-02-02 12:05:20
4
I have a table where I need to group the content on a timestamp. Any
record that is less than say 5 minutes from any other record needs to
be grouped with that other record.
ID timestamp
1 2004-02-02 12:00:00
2 2004-02-02 12:00:05
3 2004-02-02 12:05:20
4 2004-02-02 12:15:00
5
On 2004-02-10, at 16.21, Brian Power wrote:
I'm not sure if it is possible to do with a group by
Say you had
1 2004-02-02 12:00:00
2 2004-02-02 12:00:05
3 2004-02-02 12:00:09
4 2004-02-02 12:00:12
this would require 1,2 and 3 in one group and
2,3,4 in another. My understanding is that
Bengt Lindholm wrote:
In your example they would all be in the same group. You could say the
group delimiter is any gap between records that is 5 minutes or more. So
records would be in the same group even if the total timespan for the
group is more than 5 minutes, but all gaps between
At 20:21 +0100 12/17/02, Csongor Fagyal wrote:
Hi,
I have two tables: one holding bids for an auction (table bids) and
one holding user data who placed the bids (users). I would like to
get the highest bid, the user who placed the bid and the number of
bids placed, so I use the following
I have two tables: one holding bids for an auction (table bids) and
one holding user data who placed the bids (users). I would like to get
the highest bid, the user who placed the bid and the number of bids
placed, so I use the following query:
SELECT MAX(bids.amount) AS amount,
Hi,
I have two tables: one holding bids for an auction (table bids) and one
holding user data who placed the bids (users). I would like to get the
highest bid, the user who placed the bid and the number of bids placed,
so I use the following query:
SELECT MAX(bids.amount) AS amount,
I'm relatively new to the construction of complex queries,
and I'm trying to figure one out that I'm sure is common;
I wasn't able to find anything especially helpful in the docs.
Suppose I have the canonical database of CDs, with one table,
which includes fields for title, cost, and
select date_format(datepurch,'%Y-%m') as MONTH, count(*), sum(cost)
from cd
group by MONTH
Date: Fri, 12 Apr 2002 14:57:55 -0400
From: Jesse Sheidlower [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Newbie GROUP-type question
I'm relatively new to the construction of complex
I have a query that is using Group By Title.
Is there anyway to make 2 Titles such as League of their own and
League of their own### group as the same. I am removing the #'s in the
output but I still get 2 results - 1 for each. Ideas?
Sir, try
SELECT g1.name, g1.score, g1.id
FROM grades g1, grades g2
WHERE g1.name = g2.name
GROUP BY g1.name, g1.score
HAVING Max(g1.score) = Max(g2.score);
Bob Hall
Q: I have the following table "grades".
++++
| name | score |id |
41 matches
Mail list logo