Re: Group by question

2011-01-20 Thread dan
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

Re: Group by question

2011-01-17 Thread Steve Meyers
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

Re: Group by question

2011-01-17 Thread Jørn Dahl-Stamnes
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

Re: Group by question

2011-01-17 Thread Luciano Furtado
-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,

Group by question

2011-01-16 Thread Jørn Dahl-Stamnes
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;

Select w/ group by question

2010-07-14 Thread Scott Mullen
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

Re: Select w/ group by question

2010-07-14 Thread Peter Brawley
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

Re: Select w/ group by question

2010-07-14 Thread Michael Satterwhite
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.

RE: Select w/ group by question

2010-07-14 Thread Martin Gainty
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

Re: Select w/ group by question

2010-07-14 Thread Scott Mullen
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(

Stupid GROUP BY question

2009-09-25 Thread Jerry Schwartz
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

Re: Stupid GROUP BY question

2009-09-25 Thread Peter Brawley
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

RE: Stupid GROUP BY question

2009-09-25 Thread Gavin Towey
, 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

Group by question

2009-01-07 Thread Phil
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

Re: Group by question

2009-01-07 Thread Peter Brawley
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

Re: Group by question

2009-01-07 Thread Niteen Acharya
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

Re: MAX() and GROUP BY question

2006-11-12 Thread Jochem van Dieten
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

RE: MAX() and GROUP BY question

2006-11-11 Thread Tim Lucia
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

Re: MAX() and GROUP BY question

2006-11-11 Thread [EMAIL PROTECTED]
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

MAX() and GROUP BY question

2006-11-10 Thread [EMAIL PROTECTED]
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

Re: Group By question

2006-08-31 Thread Visolve DB TEAM
: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

Re: Group By question

2006-08-31 Thread mizioumt
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

Group By question

2006-08-30 Thread Chris W
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

Re: Group By question

2006-08-30 Thread Peter Brawley
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

GROUP BY question

2006-05-11 Thread Fan, Wellington
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

Re: Group By Question

2004-10-13 Thread Harald Fuchs
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:

RE: Group By Question

2004-10-13 Thread Fan, Wellington
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

Group By Question

2004-10-12 Thread Fan, Wellington
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 |

select all and group by question

2004-07-28 Thread mhirons
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:

Re: select all and group by question

2004-07-28 Thread SGreen
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

Re: GROUP BY question

2004-02-11 Thread Roger Baklund
* 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

GROUP BY question

2004-02-10 Thread 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 2004-02-02 12:15:00 5

Re: GROUP BY question

2004-02-10 Thread Bengt Lindholm
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

Re: GROUP BY question

2004-02-10 Thread Jochem van Dieten
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

Re: JOIN + GROUP BY question

2002-12-19 Thread Paul DuBois
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

Re: JOIN + GROUP BY question

2002-12-18 Thread Csongor Fagyal
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,

JOIN + GROUP BY question

2002-12-17 Thread Csongor Fagyal
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,

Newbie GROUP-type question

2002-04-12 Thread Jesse Sheidlower
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

Re: Newbie GROUP-type question

2002-04-12 Thread Bill Easton
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

Group By Question

2001-05-22 Thread Carl Schrader
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?

Re: GROUP BY Question (p2)

2001-03-30 Thread Bob Hall
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 |