RE: Group By Problem

2011-02-08 Thread Peter He
You need to group by event_text, not obj_text: select source_id ,event_text,count(*) from event_loc group by source_id,event_text; > Date: Tue, 8 Feb 2011 16:31:39 +0530 > From: adarsh.sha...@orkash.com > To: mysql@lists.mysql.com > Subject: Group By Problem > > Dear all, > > I stuck arou

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

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 >

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 optimization

2009-08-16 Thread Suhail Doshi
Peter, I am fairly certain, it's not slow because of the event_id look up but because of the GROUP BY Suhail On Sun, Aug 16, 2009 at 2:56 PM, Peter Brawley wrote: > Suhail, > > Having problems with this query, any ideas on how to optimize this further? > > Did you try writing the event_ids in

Re: Group by optimization

2009-08-16 Thread Peter Brawley
Suhail, Having problems with this query, any ideas on how to optimize this further? Did you try writing the event_ids in your IN() list to a temp table & joining to that table? PB - Suhail Doshi wrote: Having problems with this query, any ideas on how to optimize this further? mysql> e

RE: Group by column and Sum another

2009-07-20 Thread Hagen
Thanks! That did the trick. -Original Message- From: Olexandr Melnyk [mailto:omel...@gmail.com] Sent: Monday, July 20, 2009 10:02 AM To: mysql@lists.mysql.com Subject: Re: Group by column and Sum another select contract , sum(amlp) from maintenance group by contract; On Mon, Jul 20

Re: Group by column and Sum another

2009-07-20 Thread Olexandr Melnyk
select contract , sum(amlp) from maintenance group by contract; On Mon, Jul 20, 2009 at 6:50 PM, Hagen wrote: > I am hoping I can get some help with a query I am trying to construct: > > I want to group by a 'contract' column and get the sum of the 'amlp' column > values associated with each

RE: group by different time period than functions allow

2009-06-11 Thread Rolando Edwards
do Edwards [mailto:redwa...@logicworks.net] Sent: Thursday, June 11, 2009 12:34 PM To: Andrey Dmitriev; mysql@lists.mysql.com Subject: RE: group by different time period than functions allow SELECT DT DT1,DATE_ADD(DT,INTERVAL 1 WEEK) DT2 FROM (SELECT DATE_ADD(DATE(DATE_ADD(NOW(),INTERVAL (DOW-DAY

RE: group by different time period than functions allow

2009-06-11 Thread Rolando Edwards
SELECT DT DT1,DATE_ADD(DT,INTERVAL 1 WEEK) DT2 FROM (SELECT DATE_ADD(DATE(DATE_ADD(NOW(),INTERVAL (DOW-DAYOFWEEK(NOW())) DAY)),INTERVAL HR HOUR) DT FROM (SELECT 4 DOW,9 HR) AA) A; This query will produce the previous Wed at 9AM to the next Wed 9AM. Run it in the MySQL Client and note the output:

Re: Group by question

2009-01-07 Thread Niteen Acharya
Hello, I think following query would help you For Ascending select cpid,sum(score),team from j group by cpid order by sum(score) For Descending select cpid,sum(score),team from j group by cpid order by sum(score) desc Thanks! 2009/1/7 Phil > A question on grouping I've never been able to sol

Re: Group by question

2009-01-07 Thread Peter Brawley
Phil >is there any way to modify this query so that it would >return the team having the most entries? See "Within-group aggregates" at http://www.artfulsoftware.com/queries.php PB - Phil wrote: A question on grouping I've never been able to solve... create table j (proj char(3), id int

Re: Group by function and avg on char

2008-03-28 Thread Peter Brawley
Phil, If in the 2nd query you want teams with the highest count per cpid found in the first query, I think you can map the 'Avoiding repeat aggregation' pattern (http://www.artfulsoftware.com/infotree/queries.php) to your problem PB - Phil wrote: Hi all, got a simple problem I'm tryi

Re: Group By and IF statement

2007-11-08 Thread Enrique Sanchez Vela
--- mysqlman <[EMAIL PROTECTED]> wrote: > > I am attempting to get a simple query working: > > select *,MAX(a.teaching_date) as max, > MIN(a.teaching_date) as min from > teaching a, topic_cat b where a.teaching_topic = > b.topic_id or > a.teaching_topic = 999 group by a.teaching_topic > order b

Re: Group By and IF statement

2007-11-08 Thread yaya sirima
Try to enumerate the different fields changing that * (the star) > select *,MAX(a.teaching_date) as max, MIN(a.teaching_date) as min from teaching a, topic_cat b where a.teaching_topic = b.topic_id or a.teaching_topic = 999 group by a.teaching_topic order by a.teaching_date DESC 2007/11/8, mysqlm

Re: Group by time range.

2007-10-30 Thread Peter Brawley
Chris, What I want to do is find all the groups where the inserts all happened with in say 10 seconds. So my group by would be more like.. Perhaps the easiest solution is to make a temp table of datetime ranges from the resultset, then join from and group by those rowIDs. PB - Chr

Re: Group by time range.

2007-10-30 Thread Baron Schwartz
Hi, Chris W wrote: I have the following query... SELECT CreateDate, count( * ) FROM `userprofile` GROUP BY CreateDate It isn't exactly what I want. Records are added to this table in 2 main ways. First people use the web site interface to create records. In this case, records are only added

Re: GROUP BY...not using index?

2007-09-13 Thread Michael Dykman
Also, if a significant number of your records have the 'active' attribute assigned to 1, hte query optimizer will see it as more efficient to do a full table scan rather go through all the indirection layers the index imposes. - michael On 9/13/07, Les Fletcher <[EMAIL PROTECTED]> wrote: > If I

Re: GROUP BY...not using index?

2007-09-13 Thread Les Fletcher
If I am not mistaken, group by only uses an index if the index is first used as part of the where clause and is compared to a constant. You'd need a two column index for this query: INDEX(active,food) The 'active' part would be used in the where clause, and the second part ( "food" ) could t

Re: Group By / Order BY

2007-03-17 Thread Peter Brawley
70316 2this is version 2 This was the first one today but agian we needed to update. does that make sense? - Original Message - From: "Olexandr Melnyk" <[EMAIL PROTECTED]> To: "Justin" <[EMAIL PROTECTED]>; Sent: Saturday, March 17,

Re: Group By / Order BY

2007-03-17 Thread Justin
0316 2this is version 2 This was the first one today but agian we needed to update. does that make sense? - Original Message - From: "Olexandr Melnyk" <[EMAIL PROTECTED]> To: "Justin" <[EMAIL PROTECTED]>; Sent: Saturday, March 17, 200

Re: Group By / Order BY

2007-03-17 Thread Olexandr Melnyk
1) ORDER BY is executed after GROUP BY; 2) In ORDER BY don't use columns that aren't in GROUP BY, unless it's an aggregated value; Your query can be rewritten as: select date , max(rev) as max_rev from table group by date order by max_rev desc 2007/3/17, Justin <[EMAIL PROTECTED]>:

RE: group by/select issue..

2007-01-04 Thread ddevaudreuil
f the query and it'll give you some details of the query plan. Donna "bruce" <[EMAIL PROTECTED]> 01/04/2007 01:45 PM Please respond to <[EMAIL PROTECTED]> To <[EMAIL PROTECTED]> cc Subject RE: group by/select issue.. thanks for the derived tbl appr

RE: group by/select issue..

2007-01-04 Thread bruce
having to hit the db a number of times... thoughts/comments/ thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, January 04, 2007 10:01 AM To: [EMAIL PROTECTED] Cc: 'Chris White'; mysql@lists.mysql.com; 'Peter Bradley' Subjec

RE: group by/select issue..

2007-01-04 Thread ddevaudreuil
[EMAIL PROTECTED]> cc "'Chris White'" <[EMAIL PROTECTED]>, Subject RE: group by/select issue.. hi peter i must be missing something. the following is my actual schema. i have a test tbl with ~2900 rows... only a few of the rows have a

RE: group by/select issue..

2007-01-04 Thread bruce
27;; mysql@lists.mysql.com Subject: Re: group by/select issue.. Bruce, Try: SELECT DISTINCT NAME FROM DOG WHERE STATUS != 3 Should do the trick. You obviously don't want the STATUS field. If you include it, you'll get more than one line per name. Similarly for ID. If you want

Re: group by/select issue..

2007-01-04 Thread Peter Bradley
7 AM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: Re: group by/select issue.. bruce wrote: i'm trying to figure out how to create a select query that groups the tbl around 'name' such that if i want all names that do not have a status=3, i'd get a single row for &#

RE: group by/select issue..

2007-01-04 Thread bruce
eturn the other status that aren't equal to '3' for the given name... -Original Message- From: Chris White [mailto:[EMAIL PROTECTED] Sent: Thursday, January 04, 2007 9:07 AM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: Re: group by/select issue.. bruce wrote:

Re: group by/select issue..

2007-01-04 Thread Chris White
bruce wrote: i'm trying to figure out how to create a select query that groups the tbl around 'name' such that if i want all names that do not have a status=3, i'd get a single row for 'sue' and 'bob' I'm not sure why `SELECT name FROM dog WHERE status = 3 GROUP BY name;` wouldn't give you wha

Re: group by problem

2006-10-16 Thread chris smith
On 10/16/06, kalin mintchev <[EMAIL PROTECTED]> wrote: > > but that will get you all records for that category not just the most > recently updated. > that's the main problem, isn't it? what i'm looking for is the last record for EACH of the categories in the table. i'm aware of the aformentio

Re: group by problem

2006-10-16 Thread kalin mintchev
> > but that will get you all records for that category not just the most > recently updated. > that's the main problem, isn't it? what i'm looking for is the last record for EACH of the categories in the table. i'm aware of the aformentioned options. my problem with group by is that ignores th

Re: group by problem

2006-10-16 Thread Chris
kalin mintchev wrote: Basically you can't do what you want either without temporary tables or using a subselect. Subselects are only available in mysql 4.1+ (I think - check the docs) so that may or may not be an option. thanks... pardon my ignorance - how would i do that using subselects? Wi

Re: group by problem

2006-10-16 Thread kalin mintchev
> > Basically you can't do what you want either without temporary tables or > using a subselect. Subselects are only available in mysql 4.1+ (I think > - check the docs) so that may or may not be an option. thanks... pardon my ignorance - how would i do that using subselects? > -- MySQL Gen

Re: group by problem

2006-10-16 Thread Chris
kalin mintchev wrote: hi all... i have an issue with group by and ordering. apparently group by ignores 'order by id DESC'?! an example is a table that has an id and a category fields. there are a few categories under which records can be filed. so what i want is the latest record from each

Re: Group by and concatenate

2006-10-11 Thread Dan Buettner
Andrew, very possible, have a look at the GROUP_CONCAT function: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html Dan On 10/11/06, Andrew Braithwaite <[EMAIL PROTECTED]> wrote: Hi, I have the following data: mysql> select Dealername,pc from ford_gb where pc='LE4 7SL'; +---

RE: Group by and concatenate

2006-10-11 Thread Andrew Braithwaite
Never mind. mysql> select Dealername,pc,group_concat(pc) from ford_gb where pc='LE4 7SL' group by 1; ++-+--+ | Dealername | pc | group_concat(pc) | ++-+--+ | CD Bramall - Leicester | LE

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 a tab

Re: Group By question

2006-08-30 Thread Visolve DB TEAM
006 3: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 howmany>1; PB

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 howmany>1; PB - Chris W wrote: I have a table of people with one of the fields being

Re: Group by with an IF

2006-08-14 Thread Brent Baisley
The problem is your GROUP BY on celec_id. MySQL is doing the grouping and thus only grabbing the first season_week_date value within the grouping. I'm not sure what end result your are looking for. Grouping additionally by season_week_date might be what you are looking for. GROUP BY r.celeb_id,

Re: Group by with an IF

2006-08-13 Thread Chris
Steffan A. Cline wrote: I have the following query: select *, if( season_week_date = "2006-08-16", "on", "off" ) as stat, sum(overall_points) as total_points from rosters r left join celebs c on c.celeb_id = r.celeb_id where season_id=5062 and user_id=1 group by r.celeb_id order by overall

Re: Group by base on latest time field, possible?

2006-08-10 Thread Johan Höök
" <[EMAIL PROTECTED]> To: "The Nice Spider" <[EMAIL PROTECTED]>; Sent: Thursday, August 10, 2006 12:43 PM Subject: RE: Group by base on latest time field, possible? Try select thread, subject, max(time) from jos_sb_messages group by thread order by 3 -Original Messag

Re: Group by base on latest time field, possible?

2006-08-09 Thread The Nice Spider
not works. it's still show same result. any idea? - Original Message - From: "Quentin Bennett" <[EMAIL PROTECTED]> To: "The Nice Spider" <[EMAIL PROTECTED]>; Sent: Thursday, August 10, 2006 12:43 PM Subject: RE: Group by base on latest time field

RE: Group by base on latest time field, possible?

2006-08-09 Thread Quentin Bennett
Try select thread, subject, max(time) from jos_sb_messages group by thread order by 3 -Original Message- From: The Nice Spider [mailto:[EMAIL PROTECTED] Sent: Thursday, 10 August 2006 4:10 p.m. To: mysql@lists.mysql.com Subject: Group by base on latest time field, possible? I want the

Re: GROUP BY *column* when *column* is NOT in SELECT list?

2006-05-11 Thread Paul DuBois
At 18:28 -0400 5/11/06, Fan, Wellington wrote: Hello all, I have inherited this query: SELECT events.eventID AS id, attribute_master.attributeID AS attrib_id FROM events, attribute_master WHERE events.status='8' AND events.eventReview!='' AND

Re: Group By over many colums

2006-01-19 Thread Marco Neves
sends" table? > -- > Dave > > > - Original Message - > From: "Marco Neves" <[EMAIL PROTECTED]> > To: "Critters" <[EMAIL PROTECTED]> > Cc: > Sent: Thursday, January 19, 2006 4:20 PM > Subject: Re: Group By over many colums >

Re: Group By over many colums

2006-01-19 Thread Critters
- Original Message - From: "Marco Neves" <[EMAIL PROTECTED]> To: "Critters" <[EMAIL PROTECTED]> Cc: Sent: Thursday, January 19, 2006 4:20 PM Subject: Re: Group By over many colums Hi Critters, The problem is that as your MySQL is 4.0.21 don't suport the subs

Re: Group By over many colums

2006-01-19 Thread Marco Neves
Hi Critters, The problem is that as your MySQL is 4.0.21 don't suport the subselect you would need to do the group. I was thinking and you have another alternative: CREATE TEMPORARY table tdata (SELECT f1 as 'domain' from sends) union all (SELECT f2 as 'domain' from sends) unio

Re: Group By over many colums

2006-01-19 Thread Critters
quot; <[EMAIL PROTECTED]> To: Cc: "Critters" <[EMAIL PROTECTED]> Sent: Thursday, January 19, 2006 3:34 PM Subject: Re: Group By over many colums Hi, To this on I just see a solution, that depends on sub-selects, so it's available from Mysql 4.1 forward: SELECT name,

Re: Group By over many colums

2006-01-19 Thread Marco Neves
union all (SELECT f2 as domain > > Can you spot where I am going wrong? > - > David Scott > > > - Original Message - > From: "Marco Neves" <[EMAIL PROTECTED]> > To: > Cc: "Critters" <[EMAIL PROTECTED]> > Sent: Thursday, January 19, 2006 3:

Re: Group By over many colums

2006-01-19 Thread Critters
TECTED]> To: Cc: "Critters" <[EMAIL PROTECTED]> Sent: Thursday, January 19, 2006 3:34 PM Subject: Re: Group By over many colums Hi, To this on I just see a solution, that depends on sub-selects, so it's available from Mysql 4.1 forward: SELECT name,count(*) from ((S

Re: Group By over many colums

2006-01-19 Thread Marco Neves
Hi, To this on I just see a solution, that depends on sub-selects, so it's available from Mysql 4.1 forward: SELECT name,count(*) from ((SELECT name1 name FROM ) UNION ALL (SELECT name2 name FROM ) UNION ALL (SELECT name3 name FROM )) tab GROUP by name; Hope this solves you problem. mpneves

RE: Group By over many colums

2006-01-19 Thread Patrick Herber
I would suggest a union SELECT name, count(*) FROM (SELECT name1 as name from mytable union select name2 as name from mytable union select name3 as name from table) GROUP BY name but perhaps there's a better way... Regards, Patrick > -Original Message- > From: Critters [mailto:[EMAIL

Re: GROUP BY / HAVING / Aggregrates

2005-11-10 Thread Scott Hamm
On 11/10/05, Peter Brawley <[EMAIL PROTECTED]> wrote: > Scott, > > >I created a report that shows effiency for each associate (K.AID). I > >am trying to figure out how to use GROUP BY to AVG(Effiency) for each > >K.AID in subquery. Originally I used temporary tables (4) to figure > >out the ave

Re: GROUP BY / HAVING / Aggregrates

2005-11-10 Thread Peter Brawley
Scott, >I created a report that shows effiency for each associate (K.AID). I >am trying to figure out how to use GROUP BY to AVG(Effiency) for each >K.AID in subquery. Originally I used temporary tables (4) to figure >out the average effiency for each K.AID. That often left hanging >temporary tab

Re: 'GROUP BY' behavior

2005-10-31 Thread Michael Stassen
Bill Adams wrote: Shawn, That's a very reasonable answer. Thanks for pointing me to the examples. This one addresses the second question: http://dev.mysql.com/doc/refman/4.1/en/example-maximum-column-group-row. html . There is no example answering both questions in one query. Regards, Bill

RE: 'GROUP BY' behavior

2005-10-28 Thread Bill Adams
Shawn, That's a very reasonable answer. Thanks for pointing me to the examples. This one addresses the second question: http://dev.mysql.com/doc/refman/4.1/en/example-maximum-column-group-row. html . There is no example answering both questions in one query. Regards, Bill __

Re: GROUP BY Destroys 2nd Function

2005-10-28 Thread David Blomstrom
--- [EMAIL PROTECTED] wrote: > <<<>>> > > David, is it at all intuitive to organize your > geography into a tree-type > structure? Here is an example: > > Western Hemisphere (hemisphere) > C. America (continent) > Guatemala (country) > N. America (continent) >

Re: 'GROUP BY' behavior

2005-10-28 Thread SGreen
"Bill Adams" <[EMAIL PROTECTED]> wrote on 10/28/2005 01:49:28 PM: > All, > > In the following query, some of the values are averaged over several > rows, but some are not: > > SELECT hostname, volname, qtreename, round(avg(used/allocated*100),0), >round(avg(used)), allocated, available >

Re: GROUP BY Destroys 2nd Function

2005-10-28 Thread SGreen
<<<>>> David, is it at all intuitive to organize your geography into a tree-type structure? Here is an example: Western Hemisphere (hemisphere) C. America (continent) Guatemala (country) N. America (continent) Canada (country)

Re: GROUP BY Destroys 2nd Function

2005-10-28 Thread David Blomstrom
--- Jigal van Hemert <[EMAIL PROTECTED]> wrote: > > ANIMALS TABLE > > Canis_lupus | wolf > > Panthera_tigris | tiger > > > > JOIN TABLE > > SPECIES | ECOREGION > > Canis_lupus | NA1008 > > Canis_lupus | NA1010 > > > > ECOREGIONS TABLE > > ID | NAME | Geog | Geog2 > > NA1008 | Alaska tundra | na

Re: GROUP BY Destroys 2nd Function

2005-10-28 Thread Jigal van Hemert
David Blomstrom wrote: I have a PHP script that displays data like this: Eurasia Eurasiaisland Africa Where Eurasia and Africa are mainland parents of ecological regions and Eurasiaisland is a parent of an ecological system that is associated with a continent. For example, Borneo would be Eurasi

Re: GROUP BY approximation

2005-07-22 Thread Dan Nelson
In the last episode (Jul 22), Andy McHargue said: > I have table with very similar values in one field, > > count word > - > 2 APPLE > 6 APPLES > 1 APPEL > > select *,sum(count) as total from table group by word will leave > these rows separated. > > So I want to GROUP BY that field to

Re: Group by Month

2005-07-21 Thread Gleb Paharenko
Hello. Please, provide more information about your data structure and what would you want to get from the query. These manual pages might be helpful: http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html http://dev.mysql.com/doc/mysql/en/group-by-functions.html Jer

RE: Group by Month

2005-07-20 Thread Edwin Cruz
group by date_format(field_type_date,'%Y/%m' ) -Original Message- From: Jerry Swanson [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 20, 2005 1:08 PM To: mysql@lists.mysql.com Subject: Group by Month I have query that pulls data between to dates. How to group the data by month? --

RE: Group by Month

2005-07-20 Thread Jay Blanchard
[snip] I have query that pulls data between to dates. How to group the data by month? [/snip] It would be better if you showed use the query, but heh...our mind reading skills are getting pretty good. At the end of your query put the line; GROUP BY month -- MySQL General Mailing List For list a

Re: Group By query optimization

2005-07-15 Thread Andrew Braithwaite
Hi, Put indexes on 'valid' and 'sessiontype' and all will be good. Cheers, Andrew On 15/7/05 18:26, "Kishore Jalleda" <[EMAIL PROTECTED]> wrote: > Hi All, > I have a mysql query which takes 8 seconds to run ona dual > xeon 2.4, 3Gig ram box, > SELECT gamename, MAX(score) AS score, C

Re: GROUP BY ORDER BY

2005-05-31 Thread Michael Stassen
GROUP BY returns grouped columns and aggregate functions, not rows. You are grouping on history.person_id, so it makes no sense to select any column that does not have a unique value for each history.person_id. Indeed, other systems wouldn't even allow selecting non-grouped columns

re: group by day of week and group by hour in day

2005-04-27 Thread SGreen
James Black <[EMAIL PROTECTED]> wrote on 04/27/2005 10:36:20 AM: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I am curious if there is a simple way to do this. I was just asked to > give some data that requires me to group by day of week and also group > by hour in day (two different pag

re: group by day of week and group by hour in day

2005-04-27 Thread James Black
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I am curious if there is a simple way to do this. I was just asked to give some data that requires me to group by day of week and also group by hour in day (two different pages). Thanx for any help. - -- "Love is mutual self-giving that ends in self-

Re: Group By - Is there a way to set which rows values are used for the fields not in the Group By clause?

2005-04-19 Thread Rich Carr
Thank you so much Vivian! Your first solution was exactly what I was looking for! It works perfectly! Thanks so much! Richard Vivian Wang <[EMAIL PROTECTED]> wrote: create table temp select * from viewvisitor order by lastviewtime desc; select app, itemid, ownerid, visitorid, vusername,last

Re: Group By - Is there a way to set which rows values are used for the fields not in the Group By clause?

2005-04-18 Thread Vivian Wang
create table temp select * from viewvisitor order by lastviewtime desc; select app, itemid, ownerid, visitorid, vusername,lastviewtime, sum(viewcount) AS totalcount, itemname from temp where ownerid = 2 GROUP BY concat( app, itemid ) ORDER BY totalcount; or if you only care about max(lastviewtim

Re: Group By - Is there a way to set which rows values are used for the fields not in the Group By clause?

2005-04-12 Thread Rich Carr
Thanks again! Dan Bolser <[EMAIL PROTECTED]> wrote:On Tue, 12 Apr 2005, Rich Carr wrote: >Hi Dan, > Thanks very much! First, I can't figure out how to reply to this so >that it shows up in the MySQL list. How does one do it? erm... if you hit 'reply all' or answer yes to 'reply to all' it should

Re: Group By - Is there a way to set which rows values are used for the fields not in the Group By clause?

2005-04-12 Thread Dan Bolser
On Tue, 12 Apr 2005, Rich Carr wrote: >Hi Dan, > Thanks very much! First, I can't figure out how to reply to this so >that it shows up in the MySQL list. How does one do it? erm... if you hit 'reply all' or answer yes to 'reply to all' it should send mail to [EMAIL PROTECTED] Ahhh...I see what

Re: Group By - Is there a way to set which rows values are used for the fields not in the Group By clause?

2005-04-12 Thread Dan Bolser
I think the suggestion posted here... http://lists.mysql.com/mysql/182424 should get you going in the right direction. You really need to know what you are doing to know if it is giving you the correct answer or not. It would be cool if their was something like a GROUP_ROW(cols, expr) to do wh

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread Michael Genereux
Just keep in mind that the ORDER BY will require MySQL to take the full resultset and reorder it in a temporary table. MySQL has extended the GROUP BY clause as of version 3.23.34 so that you can also specify ASC and DESC after columns named in the clause. On Wed, 30 Mar 2005 10:53:38 -0500 (EST)

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread Asad Habib
Sorry for the confusion. In this case I am using the * to denote a field name instead of the wild card character. - Asad On Wed, 30 Mar 2005 [EMAIL PROTECTED] wrote: > Asad Habib <[EMAIL PROTECTED]> wrote on 03/30/2005 10:53:38 AM: > > > Does MySQL 4.1 support the use of GROUP BY and ORDER BY u

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread SGreen
Asad Habib <[EMAIL PROTECTED]> wrote on 03/30/2005 10:53:38 AM: > Does MySQL 4.1 support the use of GROUP BY and ORDER BY used in > conjunction with one another? I have tried to execute several queries > with both these clauses but the result set I get is different from what I > expect. My querie

Re: Group by datetime [SUMMARY]

2005-03-29 Thread Jason Dixon
On Mar 29, 2005, at 10:38 PM, Jason Dixon wrote: Anyways, I have a simple schema that stores some IP accounting data. I'm attempting to extract the data, grouping by the service type ("label"), and also grouping by each 24-hour window/day from the datetime column ("timestamp"). I'm not sure ho

RE: GROUP BY Clause

2005-02-25 Thread Tom Crimmins
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

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)

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 and results

2004-09-15 Thread Michael Stassen
They should return the same values, but possibly in a different order. SELECT foo, bar, baz FROM table GROUP BY foo, bar, baz; returns the values of foo, bar, and baz, once for each unique combination, ordered by foo, bar, baz. That is, GROUP BY does a free ORDER BY. SELECT DISTINCT foo, bar,

Re: Group by and results

2004-09-15 Thread Rhino
- Original Message - From: "Scott Haneda" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 15, 2004 8:12 PM Subject: Group by and results > Are these 2 statements the same? > > tSql1 = select distinct foo, bar, baz from table > tSql2 = select foo, bar, baz from tab

RE: group by issue...??

2004-09-13 Thread SGreen
type > > and i still only get a single row for each type, where i would expect to get > the ~5000 rows, grouped around the 3 different types. > > what's going on > > thanks... > > -bruce > > > -Original Message- > From: Paul DuBois [mail

RE: group by issue...??

2004-09-10 Thread bruce
ECTED] Sent: Friday, September 10, 2004 4:36 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: group by issue...?? At 16:27 -0700 9/10/04, bruce wrote: >hi... > >if i do this... > >select >h1.itemID as hitem, >h1.process as process, >h1.status as status, >h1.tblTyp

RE: group by issue...??

2004-09-10 Thread Paul DuBois
[EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: group by issue...?? At 16:27 -0700 9/10/04, bruce wrote: hi... if i do this... select h1.itemID as hitem, h1.process as process, h1.status as status, h1.tblType as tbl, h1.date as date from historyTBL as h1 where (h1.tblType = '3' or h1.tb

RE: group by issue...??

2004-09-10 Thread Paul DuBois
At 16:51 -0700 9/10/04, bruce wrote: paul forgive me for being a neophyte!!! but i have no idea how what you said helps me get to how i can actually get a grouping is there anyway to get a grouping... is there some other way to accomplish this..? am i totally lost! If you just want to s

RE: group by issue...??

2004-09-10 Thread bruce
4 | | 160 | 160 | 1 | 0 |3 | 2004-09-11 > 12:23:15 | > +--+---+--+---+-++--+--- > --+ > > i was thinking that a subselect might work, but couldn't get it to work... > > thanks for any pointers

Re: group by issue...??

2004-09-10 Thread Paul DuBois
At 16:27 -0700 9/10/04, bruce wrote: hi... if i do this... select h1.itemID as hitem, h1.process as process, h1.status as status, h1.tblType as tbl, h1.date as date from historyTBL as h1 where (h1.tblType = '3' or h1.tblType = '4'); i get a results table with ~5000 rows... if i add the 'group by'

Re: GROUP BY

2004-08-17 Thread Michael Stassen
Why did you quote an unrelated message? Both GROUP BYs will produce one row for each unique combination of the chosen columns. That is, the contents of the results will be identical. MySQL automatically orders results by the grouped columns, so the ordering of the resulting rows will differ bet

Re: GROUP BY optimization headscratcher

2004-08-16 Thread Brent Baisley
---+ +--+-+ Thanks so much! -Matt -Original Message----- From: ÃÃ ÃÂÃ [mailto:[EMAIL PROTECTED] Sent: Saturday, August 14, 2004 3:46 AM To: Matt Eaton Subject: Re: GROUP BY optimization headscratcher ÐÐÑÐÐÑÑÐÑÐÑÐ Matt ME> CREATE TABLE `T1`

RE: GROUP BY optimization headscratcher

2004-08-14 Thread Matt Eaton
Message- From: ÃÃ ÃÃÃÃÃÂÃ [mailto:[EMAIL PROTECTED] Sent: Saturday, August 14, 2004 3:46 AM To: Matt Eaton Subject: Re: GROUP BY optimization headscratcher ÐÐÑÐÐÑÑÐÑÐÑÐ Matt ME> CREATE TABLE `T1` ( ME> `guid` smallint(5) unsigned NOT NULL default '0', ME> `qid` small

Re: GROUP BY optimization headscratcher

2004-08-14 Thread Михаил Монашёв
Здравствуйте Matt ME> CREATE TABLE `T1` ( ME> `guid` smallint(5) unsigned NOT NULL default '0', ME> `qid` smallint(5) unsigned NOT NULL default '0', ME> `a` tinyint(2) NOT NULL default '-2', ME> `d` tinyint(2) NOT NULL default '-2', ME> KEY `IX_FW_qid` (`qid`), ME> KEY `IX_FW_d` (`d`)

RE: Group by statement

2004-08-10 Thread Lachlan Mulcahy
Ankur, Order of the GROUP BY will effect the sort order of the result and also whether or not MySQL uses an index. If the order of the fields in the GROUP BY differs from the index, it may not be utilised depending on your WHERE clause... Example of how the order is effected by GROUP BY: You hav

Re: GROUP BY vs DISTINCT - questions

2004-07-07 Thread SGreen
Q1: GROUP BY is the command that requests the SQL engine to "aggregate" sets of rows based on values in common between those rows. Those columns participating in the query that are NOT part of the aggregation key (the key is composed of the columns specified in the GROUP BY clause) must have some

RE: GROUP BY across UNION

2004-06-18 Thread SGreen
<[EMAIL PROTECTED]> Fax to: 06/18/2004 02:15 Subject: RE: GROUP BY across UNION

RE: GROUP BY across UNION

2004-06-18 Thread John McCaskey
ought about that before. Thanks, John A. McCaskey -Original Message- From: Michael McTernan [mailto:[EMAIL PROTECTED] Sent: Friday, June 18, 2004 11:16 AM To: John McCaskey Cc: [EMAIL PROTECTED] Subject: RE: GROUP BY across UNION Hi John, Depending on the size of your datasets, you

RE: GROUP BY across UNION

2004-06-18 Thread Michael McTernan
course, if the dataset is large enough, the temporary table will hit the disc, and then it will be very inefficent though. Thanks, Mike > -Original Message- > From: John McCaskey [mailto:[EMAIL PROTECTED] > Sent: 24 February 2004 17:08 > To: [EMAIL PROTECTED] > Subject: RE:

  1   2   >