Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
ON t.ClientID=c.ID LEFT JOIN tocname tc ON t.TOC=tc.toc LEFT JOIN network n ON t.NetworkID=n.ID WHERE t.toc=1 AND SUBSTRING(t.Day,1,7) = '2013-08' AND SUBSTRING(t.Day,1,7) = '2013-11') GROUP BY t.AccountID, t.ClientID, t.Service, t.NetworkID

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Jesper Wisborg Krogh
a shorter but equivalent query, you have: (SELECT t.id, t.name, SUM(val) FROM t1 t) UNION (SELECT t.id, t.name, SUM(val) FROM t2 t) GROUP BY t.id, t.name; That does not work in 5.0 either (at least in 5.0.96): ERROR 1064 (42000): You have an error in your SQL syntax; check

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Johan De Meersman
- Original Message - From: Machiel Richards machiel.richa...@gmail.com ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY t.AccountID, I suspect your query has never

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY t.AccountID, I suspect your query has never been doing what you think at all, and you need to select [fields] from ( select fields1 blahblah

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
) FROM t1 t) UNION (SELECT t.id, t.name, SUM(val) FROM t2 t) GROUP BY t.id, t.name; That does not work in 5.0 either (at least in 5.0.96): ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

Re: getting certain rows from a group by

2012-09-20 Thread Larry Martell
On Wed, Sep 19, 2012 at 6:56 PM, Rick James rja...@yahoo-inc.com wrote: my counts are 3 times too much. Without studying the code, I would guess that there is a JOIN between he data that needs COUNTing and the GROUP BY for the COUNT. That is, it collects more 'joined' rows before counting

Re: getting certain rows from a group by

2012-09-19 Thread hsv
2012/09/18 06:53 -0400, Larry Martell This works fine. But now I need to get a certain column (image_measurer_id) with each row returned that corresponds to the row from the group that has bottom = Min(bottom), bottom = Max(bottom), bottom closest to Avg(bottom), and bottom from the row where

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
:00' AND '2010-03-04 23:59:59' AND data_target.id = data_cst.target_name_id GROUP BY rollup.Target, rollup.EP ORDER BY ABS(data_cst.bottom - rollup.`Avg Bottom`) LIMIT 1 -- -- rollup is the name of the temp table that I was testing with. It contains

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
On Wed, Sep 19, 2012 at 12:04 AM, h...@tbbs.net wrote: 2012/09/18 06:53 -0400, Larry Martell This works fine. But now I need to get a certain column (image_measurer_id) with each row returned that corresponds to the row from the group that has bottom = Min(bottom), bottom = Max(bottom

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
On Wed, Sep 19, 2012 at 12:04 AM, h...@tbbs.net wrote: 2012/09/18 06:53 -0400, Larry Martell This works fine. But now I need to get a certain column (image_measurer_id) with each row returned that corresponds to the row from the group that has bottom = Min(bottom), bottom = Max(bottom

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
to the row from the group that has bottom = Min(bottom), bottom = Max(bottom), bottom closest to Avg(bottom), and bottom from the row where date_time = Max(date_time). There is a standard and ugly way of getting such a thing, but it entails repeating the table reference (supposing you want any

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
OK, I think I have this working. The last join was this: JOIN (select id, target_name_id, ep,date_time from data_cst WHERE target_name_id IN (775, 776, 777, 778, 779, 780, 45, 44, 116, 117, 118, 119, 120, 121) AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' GROUP

Re: getting certain rows from a group by

2012-09-19 Thread Larry Martell
) AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' GROUP BY target_name_id, ep, wafer_id HAVING count(*) 999) q1 JOIN (SELECT data_cstimage.name as minImage, data_cst.bottom

RE: getting certain rows from a group by

2012-09-19 Thread Rick James
my counts are 3 times too much. Without studying the code, I would guess that there is a JOIN between he data that needs COUNTing and the GROUP BY for the COUNT. That is, it collects more 'joined' rows before counting. Fixing it will probably make the query even messier. -Original

Re: getting certain rows from a group by

2012-09-19 Thread hsv
2012/09/19 14:36 -0400, Larry Martell MIN(ABS(Avg(bottom) - bottom)) Is not valid. It gives: ERROR (HY000): Invalid use of group function Yes, I had my doubts of that, for all that I suggested it. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql

getting certain rows from a group by

2012-09-18 Thread Larry Martell
, MAX(bottom) - MIN(bottom) as Ranges FROM data_cst WHERE target_name_id IN (775, 776, 777, 778, 779, 780, 45, 44, 116, 117, 118, 119, 120, 121) AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' GROUP BY target_name_id, ep, wafer_id

Re: getting certain rows from a group by

2012-09-18 Thread Peter Brawley
:00:00' AND '2010-03-04 23:59:59' GROUP BY target_name_id, ep, wafer_id HAVING count(*) 999) q1, data_target WHERE data_target.id = target_name_id GROUP BY q1.target_name_id, q1.ep; This works fine. But now I need to get a certain column (image_measurer_id) with each row

Re: getting certain rows from a group by

2012-09-18 Thread Larry Martell
IN (775, 776, 777, 778, 779, 780, 45, 44, 116, 117, 118, 119, 120, 121) AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' GROUP BY target_name_id, ep, wafer_id HAVING count(*) 999) q1, data_target WHERE data_target.id = target_name_id

RE: getting certain rows from a group by

2012-09-18 Thread Rick James
: Re: getting certain rows from a group by On Tue, Sep 18, 2012 at 7:52 AM, Peter Brawley peter.braw...@earthlink.net wrote: On 2012-09-18 5:53 AM, Larry Martell wrote: I have this query: SELECT data_target.name as Target, q1.ep as EP, COUNT(*) as Wafers

Re: getting certain rows from a group by

2012-09-18 Thread Larry Martell
(bottom) - MIN(bottom) as Ranges FROM data_cst WHERE target_name_id IN (775, 776, 777, 778, 779, 780, 45, 44, 116, 117, 118, 119, 120, 121) AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' GROUP BY target_name_id, ep, wafer_id

Re: getting certain rows from a group by

2012-09-18 Thread Larry Martell
(bottom), ... ) JOIN data_cst mn ON bottom = @min JOIN data_cst mx ON bottom = @max Can you elaborate on this? I don't see how this will give me what I need. I'm not looking for the min or max bottom - I already have that - I'm looking for the row from each group that has the min and max

RE: getting certain rows from a group by

2012-09-18 Thread Rick James
: If two rows have bottom = @min, it returns both. -Original Message- From: Larry Martell [mailto:larry.mart...@gmail.com] Sent: Tuesday, September 18, 2012 12:54 PM To: Rick James Cc: peter.braw...@earthlink.net; mysql@lists.mysql.com Subject: Re: getting certain rows from a group

Re: getting certain rows from a group by

2012-09-18 Thread Larry Martell
= rollup.EP AND data_cst.date_time BETWEEN '2010-03-04 00:00:00' AND '2010-03-04 23:59:59' AND data_target.id = data_cst.target_name_id GROUP BY rollup.Target, rollup.EP ORDER BY ABS(data_cst.bottom - rollup.`Avg Bottom`); Any way to work that into another join? Thanks! -Original Message

RE: getting certain rows from a group by

2012-09-18 Thread Rick James
= data_cst.target_name_id GROUP BY rollup.Target, rollup.EP ORDER BY ABS(data_cst.bottom - rollup.`Avg Bottom`) LIMIT 1 -- -- -Original Message- From: Larry Martell [mailto:larry.mart...@gmail.com] Sent: Tuesday, September 18, 2012 2:57 PM To: Rick James Cc: peter.braw

Re: Group expansion as part of the result

2012-03-27 Thread Dan Nelson
In the last episode (Mar 27), Paul Halliday said: Say I have: SELECT COUNT(name), name, COUNT(DISTINCT(status)) FROM table GROUP BY name and it returns: 20 paul 5 19 john 2 75 mark 3 is there a way to return what comprises DISTINCT(status) as part of the result? so: 20 paul

Re: Group expansion as part of the result

2012-03-27 Thread Paul Halliday
On Tue, Mar 27, 2012 at 3:43 PM, Dan Nelson dnel...@allantgroup.com wrote: In the last episode (Mar 27), Paul Halliday said: Say I have: SELECT COUNT(name), name, COUNT(DISTINCT(status)) FROM table GROUP BY name and it returns: 20 paul 5 19 john 2 75 mark 3 is there a way to return

Re: strange select/join/group by with rollup issue....

2012-02-08 Thread Arthur Fuller
I'm not sure your method isn't working, but try changing changing the to date part to '2012-02-08' and see what you get. HTH, Arthur

Re: strange select/join/group by with rollup issue....

2012-02-08 Thread Andy Wallace
Thanks, it seems to be working now. I just discovered WITH ROLLUP. It made me very happy on this project... On 2/8/12 2:54 AM, Arthur Fuller wrote: I'm not sure your method isn't working, but try changing changing the to date part to '2012-02-08' and see what you get. HTH, Arthur --

strange select/join/group by with rollup issue....

2012-02-07 Thread Andy Wallace
I am having a problem with select results that I don't understand. It seems to be tied up with a GROUP BY statement. Forgive the complexity of the SQL, I inherited some problematic data structuring. If I use this statement: SELECT lu_rcode_bucket.bucket AS 'BUCKET', CP_PKG.value

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-25 Thread Hal�sz S�ndor
2011/10/24 16:31 -0700, Daevid Vincent WHERE cs.customer_id = 7 GROUP BY customer_id Well, the latter line is now redundant. How will you make the '7' into a parameter? -- MySQL General Mailing List For list archives: http://lists.mysql.com

Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
7 2005-08-04 1035167192 billme 7 2004-02-08 SELECT MAX(`date`) FROM `customers_subscriptions` WHERE customer_id = 7 GROUP BY customer_id; gives me 2005-08-04 obviously, but as you all know, mySQL completely takes a crap on your face when you try what would seem

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
FROM customers_subscriptions AS cs GROUP BY customer_id) AS `x` ON s.customer_id = x.customer_id AND s.date = x.LastDate WHERE c.customer_id = 7; There are 781,270 customers (nearly 1 million) and 1,018,092

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
customers_subscriptions AS cs WHERE cs.customer_id = 7 GROUP BY customer_id ) AS `x` ON s.customer_id = x.customer_id AND s.date = x.LastDate WHERE c.customer_id = 7; To get ALL customers and their last

Partial Index with group by

2011-06-06 Thread Les Fletcher
I am trying to optimize a query that uses a group by on a varchar(255) column. The column has a large enough cardinality that a 10 character partial index uniquely covers over 99% of all values. I was hoping that this partial index would be able to help with the group by (though obviously

Re: I can't have group as a column name in a table? [SOLVED]

2011-02-25 Thread Dave M G
Aveek, Simcha, Johan, Thanks for explaining the situation. I knew there were some reserved words, but I hadn't realized there were so many. Anyway, now that I know I can protect my column names with backticks, I'm good to go. -- Dave M G -- MySQL General Mailing List For list archives:

I can't have group as a column name in a table?

2011-02-24 Thread Dave M G
MySQL users, Simple question: In one table in my database, the column was named group. I kept getting failed query errors until I renamed the column. I've never before encountered a situation where MySQL mistook a column name for part of the query syntax. Should I never use the word group

Re: I can't have group as a column name in a table?

2011-02-24 Thread Aveek Misra
question: In one table in my database, the column was named group. I kept getting failed query errors until I renamed the column. I've never before encountered a situation where MySQL mistook a column name for part of the query syntax. Should I never use the word group for column names

Re: I can't have group as a column name in a table?

2011-02-24 Thread Jo�o C�ndido de Souza Neto
, the column was named group. I kept getting failed query errors until I renamed the column. I've never before encountered a situation where MySQL mistook a column name for part of the query syntax. Should I never use the word group for column names? Seems a little silly. Is there a way to protect

Re: I can't have group as a column name in a table?

2011-02-24 Thread Simcha Younger
backticks, not quotes. `group`, not 'group'. -- Simcha Younger sim...@syounger.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: I can't have group as a column name in a table?

2011-02-24 Thread Johan De Meersman
On Thu, Feb 24, 2011 at 12:06 PM, Dave M G d...@articlass.org wrote: Should I never use the word group for column names? Seems a little silly. Is there a way to protect column names to that there is no confusion? As several people already pointed out, simply use backticks. Simple quotes have

Re: I can't have group as a column name in a table?

2011-02-24 Thread Jo�o C�ndido de Souza Neto
: Should I never use the word group for column names? Seems a little silly. Is there a way to protect column names to that there is no confusion? As several people already pointed out, simply use backticks. Simple quotes have started to work in more and more places in newer versions of MySQL

Re: I can't have group as a column name in a table?

2011-02-24 Thread mos
a great idea. I am going to change my table names to Table, Group, Having, Select, Into, Order By, Update, Delete etc. just to confuse hackers so they won't be able to launch a sql injection attack against my website. The naming convention will drive them crazy. Mike (Just kidding) On Feb 24

Re: I can't have group as a column name in a table?

2011-02-24 Thread Jo�o C�ndido de Souza Neto
) in the query. For more details refer to http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html Thanks Aveek Hmmm. Everyone has given me a great idea. I am going to change my table names to Table, Group, Having, Select, Into, Order By, Update, Delete etc. just to confuse hackers so

Group By Problem

2011-02-08 Thread Adarsh Sharma
3 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

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 around one

Re: Group by question

2011-01-20 Thread dan
:18:58 | 2011-01-16 11:13:04 | +--+-+-+ 8 rows in set (0.09 sec) The problem is that album_id 81 is occuring two times in the list. So I thought I should add a group by in the query: mysql select album_id, updated_at, created_at from album_stats

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

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
, 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 deterministic. If there are multiple rows per album_id, any one of those

Group by question

2011-01-16 Thread Jørn Dahl-Stamnes
| +--+-+-+ 8 rows in set (0.09 sec) The problem is that album_id 81 is occuring two times in the list. So I thought I should add a group by in the query: mysql select album_id, updated_at, created_at from album_stats group by album_id order by updated_at desc limit

Re: Query Stored Index instead of Group By

2010-12-20 Thread Feris Thia
Hi Johan, On Sun, Dec 19, 2010 at 7:11 PM, Johan De Meersman vegiv...@tuxera.bewrote: You can't query the index directly, but if you select only fields that are in the index, no table lookups will be performed - this is called a covering index. Great.. Thanks for the confirmation. Regards,

Re: Query Stored Index instead of Group By

2010-12-19 Thread Johan De Meersman
On Sun, Dec 19, 2010 at 3:19 AM, Feris Thia milis.datab...@phi-integration.com wrote: Hi Everyone, Is there a way to query values stored in our index instead of using group by selection which will produce same results ? You can't query the index directly, but if you select only fields

Query Stored Index instead of Group By

2010-12-18 Thread Feris Thia
Hi Everyone, Is there a way to query values stored in our index instead of using group by selection which will produce same results ? Please advice.. Regards, Feris

GROUP BY - INNER JOIN and LIMIT - how to get result

2010-11-29 Thread Arkadiusz Malka
I have tables: CREATE TABLE `tblNames` ( ` IdName` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(60) DEFAULT NULL, PRIMARY KEY (`IdName`), ) ENGINE=MyISAM CREATE TABLE `tblStatusy` ( `IdStatus` int(11) NOT NULL AUTO_INCREMENT, `IdName` int(11) DEFAULT NULL, `Status`

RE: query results group/summed by interval

2010-08-01 Thread nuno . tavares
Hi all, Aveeks solution should work if you have at least one call for each intervall. It's the classical GROUP BY solution that only works on the available dataset. Although it should work pretty well in the cited scenario, you will miss intervals (from a all intervals report point of view

RE: query results group/summed by interval

2010-08-01 Thread Travis Ard
(step.n - 5) and calls.queue_seconds = step.n group by n; +---+---+ | calls | queue_seconds | +---+---+ |   250 | 0 | |   168 | 5 | |   268 |    10 | | 0 |    15 | +---+---+ 4 rows in set (0.00 sec) -Travis

RE: query results group/summed by interval

2010-07-31 Thread Martin Gainty
no matching rows. sum(calls) from calls group by 5 * floor(seconds/5) sum(calls) from calls group by 5 * floor(5/5) sum(calls) from class group by 5 * 1 sum(calls) from class group by 5 is correct 2nd(seconds/5) interval example 10/5=2 floor(10/5)=2 supplied value would truncate and give you the int

RE: query results group/summed by interval

2010-07-31 Thread Martin Gainty
no matching rows. sum(calls) from calls group by 5 * floor(seconds/5) sum(calls) from calls group by 5 * floor(5/5) sum(calls) from class group by 5 * 1 sum(calls) from class group by 5 is correct 2nd(seconds/5) interval example 10/5=2 floor(10/5)=2 supplied value would truncate and give you the int

Re: query results group/summed by interval

2010-07-30 Thread Nguyen Manh Cuong
Hi Aveek, I think Ghulam just want to count calls for each intervals so the query should looks like this: select count(*) as total_calls, queue_seconds from calls group by queue_seconds order by total_calls; - Original Message - From: Aveek Misra ave...@yahoo-inc.com To: Ghulam Mustafa

RE: concatenate sql query with group by and having

2010-07-29 Thread Travis Ard
in -- returns all geneNames (symbols) with one unique combination of chrom and strand (select geneName from -- returns all unique combinations of symbol, chrom, and strand (select distinct geneName, chrom, strand from refFlat) sub1 group by geneName having count(*) = 1) group by refSeq having

concatenate sql query with group by and having

2010-07-28 Thread Peng Yu
symbols but different chrom and strand). Could anybody show me how to do it? select geneName as symbol, name as refSeq, chrom, strand, txStart from refFlat group by refSeq having count(*)=1; I think that something like SELECT name FROM (SELECT name, type_id FROM (SELECT * FROM foods)); works

query results group/summed by interval

2010-07-27 Thread Ghulam Mustafa
Hi everyone, i have two columns (seconds, number of calls), i need to produce a report which will show total number of calls in intervals (let'say 10 seconds interval), i know i can do this programmability in my script but i was wondering if it's possible to accomplish this behavior within mysql.

RE: query results group/summed by interval

2010-07-27 Thread Aveek Misra
try this ... select 5 * floor(seconds/5) as start, 5 * floor(seconds/5) + 5 as end, sum(calls) from calls group by 5 * floor(seconds/5); This should give you an output of the type +---+--++ | start | end | sum(calls) | +---+--++ | 0 |5

Select w/ group by question

2010-07-14 Thread Scott Mullen
products a join vendors b on a.vendor_id = b.vendor_id group by a.type, a.vendor_id, b.vendor_name all rows are returned because the type/vendor_id/vendor_name are unique amongst each row. If you remove the vendor_id and vendor_name from the group by, you get a single row with the lowest cost

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

Re: Select w/ group by question

2010-07-14 Thread Michael Satterwhite
in the result set here.) Try this: select name, product_type, min(cost) from vendors join products on vendors.id = products.vendor_id group by product_type; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

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
( MIN( CONCAT( LPAD(price,6,0),supplier) ), 7) AS MinSupplier, LEFT( MIN( CONCAT( LPAD(price,6,0),supplier) ), 6)+0 AS MinPrice, SUBSTR( MAX( CONCAT( LPAD(price,6,0),supplier) ), 7) AS MaxSupplier, LEFT( MAX( CONCAT( LPAD(price,6,0),supplier) ), 6)+0 AS MaxPrice FROM products GROUP

Re: Duplicate entries despite group by

2010-02-21 Thread Carsten Pedersen
) NOT NULL, `weight` int(10) NOT NULL, PRIMARY KEY (`tableid1`,`tupleid1`,`tableid2`,`tupleid2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 and I'm running this query (note the 'group by'): insert into graph (node1, node2, tableid1, tupleid1, tableid2, tupleid2, weight) select 0, 0

Duplicate entries despite group by

2010-02-20 Thread Yang Zhang
`,`tupleid1`,`tableid2`,`tupleid2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 and I'm running this query (note the 'group by'): insert into graph (node1, node2, tableid1, tupleid1, tableid2, tupleid2, weight) select 0, 0, a.tableid, a.tupleid, b.tableid, b.tupleid, count(*) from

Consult with group

2009-11-28 Thread armando
i have a question, i'm searching for a while and do not find some reference how to do that. a simple query return this: dato1 dato2 dato3 estado1 fecha1 dato1 dato2 dato3 estado2 fecha2 dato1 dato2 dato3 estado3 fecha3 dato4 dato5 dato6 estado1 fecha4 dato4 dato5 dato6 estado2 fecha5 dato4 dato5

Re: Consult with group

2009-11-28 Thread Dan Nelson
fecha1,fecha2,fecha3, which you can then split in your application code. Make sure you don't include your the estado or fecha columns in the GROUP BY clause (in your case you would want to group by the first three columns only). http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html

help with group by

2009-10-28 Thread Adam Williams
I've written a helpdesk ticket problem and am working on the statistics module. I'm having problems with group by. For instance, I want to get the count of the number of different problem types, by how many were solved by each person. This is my statement: mysql select distinct accepted_by

Re: help with group by

2009-10-28 Thread Michael Dykman
try this: select accepted_by, problem_type, count(*) from form where problem_type is not NULL AND problem_type != 'Test' AND accepted_by is not null group by accepted_by, problem_type On Wed, Oct 28, 2009 at 12:05 PM, Adam Williams awill...@mdah.state.ms.us wrote: I've written a helpdesk

Re: help with group by

2009-10-28 Thread Adam Williams
works perfectly, i didn't know you could use multiple columns in the group by. thanks a bunch! Michael Dykman wrote: try this: select accepted_by, problem_type, count(*) from form where problem_type is not NULL AND problem_type != 'Test' AND accepted_by is not null group by accepted_by

Performance tuning a group by with percentage

2009-10-16 Thread Scott Haneda
) AS thecount, COUNT( * ) / ( SELECT COUNT( * ) FROM agents ) AS percentage FROM agents GROUP BY user_agent_parsed ORDER BY thecount DESC LIMIT 50; Second issue, once a day I need to archive the result of the above. Any suggestions on how to best to do that? I can schedule with cron

Stupid GROUP BY question

2009-09-25 Thread Jerry Schwartz
the newest note (if any) for each customer. If all I want is the date, then I can do SELECT Cust.CustID, MAX(Notes.NoteTime) FROM Cust LEFT JOIN Notes ON Cust.CustID = Notes.Cust_ID GROUP BY Cust.CustID; That will work just fine, but now I also want the NoteText associated with the newest

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
Commonly refered to as a groupwise max http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html http://jan.kneschke.de/projects/mysql/groupwise-max/ Regards, Gavin Towey -Original Message- From: Jerry Schwartz [mailto:jschwa...@the-infoshop.com] Sent: Friday

Group by optimization

2009-08-16 Thread Suhail Doshi
15059,115146,115244,115541,115689,116305,116405,116762,117148,117296,117389,117504,117779,117945,118285,118447,118571,118752) GROUP BY cache_property_str.name ORDER BY NULL LIMIT 10

Re: Group by optimization

2009-08-16 Thread Peter Brawley
9,105909,106173,106311,106459,107118,107320,107662,107970,108155,108379,108418,108618,108779,108960,109506,109691,110067,110469,110698,110806,111201,111286,111641,112174,112375,112568,112656,113094,113248,113344,113449,113561,113909,114170,114322,114432,115059,115146,115244,115541,115689,116305,116405,116762,117148,117296,117389,117504,117779,117945,118285,118447,118571,118752) GROUP

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 peter.braw...@earthlink.netwrote: Suhail, Having problems with this query, any ideas on how to optimize this further? Did you try

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Elim PDT
| +---+---+-+ which not groups correctly. Seems it's a hard query. - Original Message - From: Darryle Steplight dstepli...@gmail.com To: Elim PDT e...@pdtnetworks.net Cc: mysql@lists.mysql.com Sent: Wednesday, July 15, 2009 11:50 PM Subject: Re: Hard? query to with group order by group

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Brent Baisley
|    NULL | |         4 | John  |       3 | |         5 | Jane  |       3 | +---+---+-+ Record with null head_id means the member is a group head. Record with head_id k are in the group with head whoes id equals k. I like to fetch the rows in the following ordaer

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Basil Daoust
| +---+---+-+ Record with null head_id means the member is a group head. Record with head_id k are in the group with head whoes id equals k. I like to fetch the rows in the following ordaer | 3 | David | NULL | | 4 | John | 3 | | 5 | Jane | 3 | | 1 | Elim | NULL | | 2 | Ann | 1

Group by column and Sum another

2009-07-20 Thread Hagen
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 contract. I can do a select and group by on contract select contract from maintenance group by contract; and I will get

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 finha...@comcast.net 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

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

what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Govinda
My table group_member looks like this: +---+---+-+ | member_id | name | head_id | +---+---+-+ | 1 | Elim |NULL | | 2 | Ann | 1 | | 3 | David |NULL | | 4 | John | 3 | | 5 | Jane | 3 |

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Govinda
I see such nice formated text output serving to illustrate people's tables and I think it must be due to some code which is spitting that out, rather than people typing so painstakingly. What is that function/MySQL/code? It's the default output format of the mysql command line client,

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Marcus Bointon
On 16 Jul 2009, at 15:02, Govinda wrote: I see such nice formated text output serving to illustrate people's tables and I think it must be due to some code which is spitting that out, rather than people typing so painstakingly. What is that function/MySQL/code? It's the default output

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Marcus Bointon
On 16 Jul 2009, at 15:26, Govinda wrote: Meaning that on a shared hosting situation, without ssh, then I cannot do that, right? Not necessarily - you can run the client locally and connect to the remote DB. It depends if your host allows remote access to mysql (they might do on

Hard? query to with group order by group head's name

2009-07-15 Thread Elim PDT
| +---+---+-+ Record with null head_id means the member is a group head. Record with head_id k are in the group with head whoes id equals k. I like to fetch the rows in the following ordaer | 3 | David |NULL | | 4 | John | 3 | | 5 | Jane

Re: Hard? query to with group order by group head's name

2009-07-15 Thread Darryle Steplight
Hi Elim, I didn't test it out but it sounds like you want to do this SELECT * FROM group_members GROUP BY head_id, member_id ORDER BY name ASC . On Thu, Jul 16, 2009 at 1:20 AM, Elim PDTe...@pdtnetworks.net wrote: My table group_member looks like

Using RANDOM before GROUP BY technique returned only a single column

2009-07-06 Thread Highviews
Hi, I am using a technique described here at: http://forums.mysql.com/read.php?20,227102,227102#msg-227102 To make results Random before applying the GROUP BY method. The query to my table structure is this: SELECT r.physicians_id, (SELECT r1.id FROM physicians_images r1 WHERE (r.physicians_id

a possible group issue???

2009-06-12 Thread bruce
to do the query, and added a group by CollegeID' with no luck.. so how can i combine the two rows to get a single row?? thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: a possible group issue???

2009-06-12 Thread Max Bube
Try with GROUP_CONCAT(ScriptName) http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat 2009/6/12 bruce bedoug...@earthlink.net Hi... I have the following... mysql INSERT INTO ParseScriptTBL VALUES - ('auburnCourse.py',40,1,1), - ('auburnFaculty.py

RE: a possible group issue???

2009-06-12 Thread bruce
hi martin... thanks for the reply.. but that still generates two separate rows as well... -Original Message- From: Martin Gainty [mailto:mgai...@hotmail.com] Sent: Friday, June 12, 2009 12:04 PM To: bruce Douglas Subject: RE: a possible group issue??? mysql select * from

group by different time period than functions allow

2009-06-11 Thread Andrey Dmitriev
Can someone point a link, or show an example. basically, i have something like select week(mydate), count(mystuff) from table group by week(mydate); however, I need week to start on Wed 9am and end next Wed. What's the easiest way to accomplish that? thanks, andrey -- MySQL General Mailing

RE: group by different time period than functions allow

2009-06-11 Thread Rolando Edwards
) 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) AAA) B Where A.mydate = B. DT1_9AM And A.mydate B. DT2_9AM group by week(A.mydate); Give it a Try !!! Rolando A. Edwards MySQL DBA (CMDBA) 155 Avenue

  1   2   3   4   5   6   7   8   9   10   >