Re: help with query to count rows while excluding certain rows

2016-01-02 Thread Larry Martell
On Fri, Jan 1, 2016 at 9:31 PM, Peter Brawley wrote: > On 1/1/2016 19:24, Larry Martell wrote: >> >> On Fri, Jan 1, 2016 at 2:12 PM, Peter Brawley >> wrote: >>> >>> On 12/31/2015 0:51, Larry Martell wrote: >>>> >>>> I need to count t

Re: help with query to count rows while excluding certain rows

2016-01-01 Thread Larry Martell
On Fri, Jan 1, 2016 at 2:12 PM, Peter Brawley wrote: > On 12/31/2015 0:51, Larry Martell wrote: >> >> I need to count the number of rows in a table that are grouped by a >> list of columns, but I also need to exclude rows that have more then >> some count when gr

Re: help with query to count rows while excluding certain rows

2016-01-01 Thread Peter Brawley
On 12/31/2015 0:51, Larry Martell wrote: I need to count the number of rows in a table that are grouped by a list of columns, but I also need to exclude rows that have more then some count when grouped by a different set of columns. Conceptually, this is not hard, but I am having trouble doing

help with query to count rows while excluding certain rows

2015-12-30 Thread Larry Martell
I need to count the number of rows in a table that are grouped by a list of columns, but I also need to exclude rows that have more then some count when grouped by a different set of columns. Conceptually, this is not hard, but I am having trouble doing this efficiently. My first counting query

Re: [ask] count items in the SET(value1,value2,value3)

2012-09-25 Thread Morning Star
On Tue, Sep 25, 2012 at 12:31 AM, Rick James wrote: > SET foo (...) > Maybe: > SELECT BIT_COUNT(foo) ... > It works. Thanks! :) Greetings, Marco -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

RE: [ask] count items in the SET(value1,value2,value3)

2012-09-24 Thread Rick James
SET foo (...) Maybe: SELECT BIT_COUNT(foo) ... > -Original Message- > From: Morning Star [mailto:morning.star.c...@gmail.com] > Sent: Monday, September 24, 2012 7:02 AM > To: mysql@lists.mysql.com > Subject: [ask] count items in the SET(value1,value2,value3) > > H

[ask] count items in the SET(value1,value2,value3)

2012-09-24 Thread Morning Star
n is: how can i count that items ( value1 till value5) ? Greetings, Marco -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

Re: distinct & count operation with the use of "where count > $num"

2012-06-17 Thread Tsubasa Tanaka
Hi, you have to use `HAVING' instead of `WHERE' like this. SELECT DISTINCT `term`, COUNT(*) AS count FROM blp_sql_distinct_temp_table GROUP BY `term` HAVING count >= 5 ORDER BY count DESC; put `HAVING' next of `GROUP BY'. `WHERE' behaves at before aggregate of `GR

distinct & count operation with the use of "where count > $num"

2012-06-17 Thread Haluk Karamete
Hi, I'm trying to get this work; SELECT distinct `term`,count(*) as count FROM blp_sql_distinct_temp_table where count >= 5 group by `term` order by count DESC But I get this error; Unknown column 'count' in 'where clause' How do I get only those records who

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-07 Thread Johan De Meersman
Good to see the issue has been solved. What I noticed in the mysqltuner output, is that you may want to enlarge your table_cache and open files limit before you run into problems there. - Original Message - > From: "Johnny Withers" > > I haven't used MYISAM in a long time, so i'm not s

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Andrew Moore
Glad you got to the bottom of it Joey. On 7 Oct 2011 01:23, "Joey L" wrote: > Guys - I wanted to thank you all very much for your help > I found the offending code on the website ! > thank you very very very much... > what did it for me was a combination of show processlist and show full >

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
Guys - I wanted to thank you all very much for your help I found the offending code on the website ! thank you very very very much... what did it for me was a combination of show processlist and show full processlist. I saw the full queries and the main thing was that it was doing a query

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Jan Steinman
> From: Joey L > > i did google search - myisam is faster...i am not really doing any > transaction stuff. That's true for read-only. But if you have a mix of reads and writes, MYISAM locks tables during writes, which could be blocking reads. In a museum in Havana, there are t

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Johnny Withers
I've sent this email a few times now, mysql list kept rejecting it due to size, sorry for any duplicates I think you need to examine this query in particular: | 2567 | p_092211 | localhost | p_092211 | Query | 11 | Sending data | select oldurl, newurl, id, dateadd from w6h8a_sh404sef_ur

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
rls WHERE newurl = 'index.php?option=com_limos&city=Armo | | 2615 | p_092211 | localhost | p_092211 | Query |7 | Locked | SELECT `oldurl`, `newurl`, `dateadd` FROM w6h8a_sh404sef_urls WHERE `oldurl`='MLF/index.php/' ORDER | | 2616 | p_092211 | localhost | p_092211 | Query |7 | Locked | SELECT * FROM w6h8a_sh404sef_urls WHERE `oldurl`='MLF/index.php' | | 2617 | p_092211 | localhost |

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Andrew Moore
Precisely my point Singer. There's a workload here that isn't friendly with table level locking and I would hazard a guess that there's some fights over IO due to load vs resources. The count is going to be queued as you describe. A On Thu, Oct 6, 2011 at 6:09 PM, Singer X.J. Wang

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Michael Dykman
nce through 2 disks and effectively 1 if in a mirrored > > configuration. The stats show that you're configured for MyISAM and that > > you're tables are taking reads and writes (read heavy though), MyISAM > > doesn't like high concurrency mixed workloads such as y

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
sks and effectively 1 if in a mirrored > configuration. The stats show that you're configured for MyISAM and that > you're tables are taking reads and writes (read heavy though), MyISAM > doesn't like high concurrency mixed workloads such as yours, it will cause > locking and ma

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Andrew Moore
ugh), MyISAM doesn't like high concurrency mixed workloads such as yours, it will cause locking and maybe thats why your count has such a delay. Such activity may be better suited to InnoDB engine (you must configure and tune for this, not JUST change the engine). HTH Andy On Thu, Oct 6, 2011 at 5:

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Andrew Moore
Joey, does your 'large' table get On Thu, Oct 6, 2011 at 3:22 PM, Joey L wrote: > here is mysqlreport --- > > root@rider:~/tmp# ./mysqlreport --user root --password barakobomb > Use of uninitialized value $is in multiplication (*) at ./mysqlreport

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
here is mysqlreport --- root@rider:~/tmp# ./mysqlreport --user root --password barakobomb Use of uninitialized value $is in multiplication (*) at ./mysqlreport line 829. Use of uninitialized value in formline at ./mysqlreport line 1227. MySQL 5.1.49-

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Rik Wasmus
> thanks for the response - but do not believe queries are the issue > because - Like I said - i have other websites doing the same exact > queries as I am doing on the site with the 9gig table. Contrary to popular believe, size DOES matter... And having a table large enough so it doesn't fit in

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Johan De Meersman
I keep finding it extremely peculiar that a count(*) on a MyISAM table would take that long. InnoDB needs to effectively *count* the records, but MyISAM keeps accurate statistics and can just read it from the metadata. This suggests to me that not all your metadata (ie., table descriptors et al

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Johnny Withers
ou may need to change. >>>> #server-id = 1 >>>> #log_bin= /var/log/mysql/mysql-bin.log >>>> expire_logs_days= 10 >>>> max_binlog_size = 100M >>>> #binlog_do_db = include_database_nam

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
e >>> # >>> # * InnoDB >>> # >>> # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. >>> # Read the manual for more InnoDB related options. There are many! >>> # >>> # * Security Features >>> # >>> # Read t

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Johnny Withers
DB related options. There are many! >> # >> # * Security Features >> # >> # Read the manual, too, if you want chroot! >> # chroot = /var/lib/mysql/ >> # >> # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". >> # >&g

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
but no tab completition > > [isamchk] > key_buffer              = 16M > > # > # * IMPORTANT: Additional settings that can override those from this file! > #   The files must end with '.cnf', otherwise they'll be ignored. > # > !includedir /etc/mysql/conf

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-06 Thread Joey L
rwise they'll be ignored. # !includedir /etc/mysql/conf.d/ any thoughts or help would be appricated. thanks On Mon, Oct 3, 2011 at 1:22 PM, Eric Bergen wrote: > Can you run show processlist in another connection while the select > count(*) query is running and say what the state column i

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-03 Thread Eric Bergen
Can you run show processlist in another connection while the select count(*) query is running and say what the state column is? On Mon, Oct 3, 2011 at 7:00 AM, Joey L wrote: > this is not a real query on the site - it is just a way i am measuring > performance on mysql - I do not know if

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-03 Thread Joey L
:58 AM, Andrés Tello wrote: > have you tried > > select count(yourindex) instead of select count(*) ? > > > On Mon, Oct 3, 2011 at 7:53 AM, Joey L wrote: > >> Thanks for the input - >> 1. I will wait 48 hours and see what happens. >> 2. can you tell me what

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-03 Thread Andrés Tello
have you tried select count(yourindex) instead of select count(*) ? On Mon, Oct 3, 2011 at 7:53 AM, Joey L wrote: > Thanks for the input - > 1. I will wait 48 hours and see what happens. > 2. can you tell me what are some performance tests I can do to help me > better tune my ser

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-03 Thread Joey L
Thanks for the input - 1. I will wait 48 hours and see what happens. 2. can you tell me what are some performance tests I can do to help me better tune my server ? 3. I am concerned about this table : | w6h8a_sh404sef_urls | MyISAM | 10 | Dynamic| 8908402 |174 |

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Bruce Ferrell
The meaning is: increase max_connections reduce wait_timeout -- 28800 is wait 8 hours before closing out dead connections same for interactive_timeout increase key_buffer_size (> 7.8G) increase join_buffer_size -- This keeps mysql from having to run to disk constantly for keys -- Key buffer siz

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Joey L
t;<" -- does > this mean I have to set it lower ?? > thanks...here is the info below you both asked for : > > > mysql> select count(*) from w6h8a_sh404sef_urls ; > > +--+ > | count(*) | > +--+ > | 8908193 | > +--+ > 1 row in

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Joey L
The section called: Variables to adjust: --when it says ">" -- does this mean I have to set it higher in my.cnf file ?? and if I have a "<" -- does this mean I have to set it lower ?? thanks...here is the info below you both asked for : mysql> select coun

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Andrew Moore
0.0 0:00.04 [migration/0] >>4 root 20 0 000 S0 0.0 0:00.16 [ksoftirqd/0] >> >> >> On Sun, Oct 2, 2011 at 9:55 AM, Andrew Moore wrote: >> >> > Is your table MyISAM or InnoDB? >> > >> > A >> > >> >

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Bruce Ferrell
I'd suggest mysqltuner. You can get it by using: wget http://mysqltuner.pl See what suggestions that makes On 10/02/2011 06:44 AM, Joey L wrote: > I have having issues with mysql db - I am doing a "select count(*) from > table" -- and it take 3 to 4 min. > My t

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Joey L
> On Sun, Oct 2, 2011 at 2:44 PM, Joey L wrote: > >> I have having issues with mysql db - I am doing a "select count(*) from >> table" -- and it take 3 to 4 min. >> My table has about 9,000,000 records in it. >> I have noticed issues on my web pages so that is

Re: 4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Andrew Moore
Is your table MyISAM or InnoDB? A On Sun, Oct 2, 2011 at 2:44 PM, Joey L wrote: > I have having issues with mysql db - I am doing a "select count(*) from > table" -- and it take 3 to 4 min. > My table has about 9,000,000 records in it. > I have noticed issues on my web

4 minute slow on select count(*) from table - myisam type

2011-10-02 Thread Joey L
I have having issues with mysql db - I am doing a "select count(*) from table" -- and it take 3 to 4 min. My table has about 9,000,000 records in it. I have noticed issues on my web pages so that is why i did this test. I have about 4 gig of memory on the server. Is there anything I can

buf/buf0buf.c:597 hi count

2010-11-11 Thread Claudio Nanni
Anyone has idea if this is normal? I have a rather hi count on some mutexes on one of my servers: Find below: - server status - last section of mutex status - full innodb status. Thanks Claudio mysql> status; -- mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-

COUNT question

2010-10-18 Thread Tompkins Neil
Hi, I've the following query SELECT COUNT(players_id) AS players_count FROM players WHERE teams_id > 0 GROUP BY teams_id ORDER BY players_count DESC However, I've another field called original_teams_id and want to include the COUNT with players_count, when original_teams_id = tea

Re: Constructing query to display item count based on increments of time

2010-10-07 Thread Johan De Meersman
math.. and the DATE_FORMAT call might not > even be needed depending on the actual application. > > select > DATE_FORMAT(start_time, "%Y-%m-%d %h:" ) as dhour, > 10*(minute(start_time)%6) as dtime ,count(*) > from table > group by dhour,dtime; > &

Re: Constructing query to display item count based on increments of time

2010-10-06 Thread Hank
me)%6) as dtime ,count(*) from table group by dhour,dtime; -Hank On Wed, Oct 6, 2010 at 4:22 PM, Johan De Meersman wrote: > Two people already who suggested a text-based approach vs. my numeric > approach. > > Analysing, my method takes a single function call per record (to_u

Re: Constructing query to display item count based on increments of time

2010-10-06 Thread Johan De Meersman
king ? :-D On Wed, Oct 6, 2010 at 5:44 PM, Hank wrote: > Here's what I came up with: > > select concat(left(DATE_FORMAT(start_time, "%Y-%m-%d %h:%i" > ),15),"0") as time, count(*) from table group by time > > -Hank > > >> > >&g

Re: Constructing query to display item count based on increments of time

2010-10-06 Thread Hank
Here's what I came up with: select concat(left(DATE_FORMAT(start_time, "%Y-%m-%d %h:%i" ),15),"0") as time, count(*) from table group by time -Hank >> >> How would one go about to construct a query that counts items within an >> increment or span

Re: Constructing query to display item count based on increments of time

2010-10-06 Thread Travis Ard
Maybe you could use something like the following to truncate your times to 10 minute increments before doing your GROUP BY and COUNT(): select concat(date_format(timestamp_col, '%Y-%m-%d %H:'), truncate(minute(timestamp_col) / 10, 0), '0') from y

Re: Constructing query to display item count based on increments of time

2010-10-06 Thread Johan De Meersman
convert to unixtime, convert your interval to unixtime, creatively combine with integer division to get a base number for each period, group by that and count(). 2010/10/6 Pascual Strømsnæs > Hi! > > How would one go about to construct a query that counts items within an > incremen

Constructing query to display item count based on increments of time

2010-10-06 Thread Pascual Strømsnæs
Hi! How would one go about to construct a query that counts items within an increment or span of time, let's say increments of 10 minutes? Imagine a simple table where each row has a timestamp, and the query should return the count of items occurring within the timespan of a defined p

RE: Update record count

2010-09-17 Thread Jerry Schwartz
>-Original Message- >From: Shawn Green (MySQL) [mailto:shawn.l.gr...@oracle.com] >Sent: Thursday, September 16, 2010 9:51 PM >To: Jerry Schwartz >Cc: mysql@lists.mysql.com >Subject: Re: Update record count > >On 9/16/2010 5:12 PM, Jerry Schwartz wrote: >> I

Re: Update record count

2010-09-17 Thread Johan De Meersman
On Fri, Sep 17, 2010 at 3:51 AM, Shawn Green (MySQL) < shawn.l.gr...@oracle.com> wrote: > > So if 10 rows of A match your conditions, 1 row from B match your > conditions, and 10 rows from C match your conditions, then this query > produces 10*1*10 total row combinations. > Umm. It's friday, so I

Re: Update record count

2010-09-16 Thread Shawn Green (MySQL)
On 9/16/2010 5:12 PM, Jerry Schwartz wrote: I should be able to figure this out, but I'm puzzled. Here's a simplified example: UPDATE a JOIN b ON a.kb = b.kb JOIN c ON b.kc = c.kc SET a.f1 = NOW(), b.f2 = NOW() WHERE c.f3 IN ('x', 'y', 'z') AND b.f4 = 'yen'; It seems to me that if there are

Update record count

2010-09-16 Thread Jerry Schwartz
I should be able to figure this out, but I'm puzzled. Here's a simplified example: UPDATE a JOIN b ON a.kb = b.kb JOIN c ON b.kc = c.kc SET a.f1 = NOW(), b.f2 = NOW() WHERE c.f3 IN ('x', 'y', 'z') AND b.f4 = 'yen'; It seems to me that if there are 3 rows found in `c` that match a total of 10

Re: Slow disk access: 1.4m to do a select count over 23GB table.

2010-07-10 Thread Andrés Tello
As usual, after you send a mail, you check for other things >From the 32GB of ram, I only was allocating 2G, not by the process, but by all the S.O... free -G reported barely 1 gig of ram... XD -> happy face that I have lots of ram... now my face is like: ¬¬ -> why I didn't verfy the amount

Re: Slow disk access: 1.4m to do a select count over 23GB table.

2010-07-10 Thread Rob Wultsch
On Fri, Jul 9, 2010 at 9:09 PM, Andrés Tello wrote: > Hi, I'm using mysql 4.1.21, a legacy system. Next step to migrate it, but > for now, I need the community help. > > I have a 23GB table, if I do a select count(over_an_index) from table it > uses 1.4minutes to read. The mai

Slow disk access: 1.4m to do a select count over 23GB table.

2010-07-09 Thread Andrés Tello
Hi, I'm using mysql 4.1.21, a legacy system. Next step to migrate it, but for now, I need the community help. I have a 23GB table, if I do a select count(over_an_index) from table it uses 1.4minutes to read. The main issue is that this table is the main table of a system and each query is t

Re: High MySQL sleep count

2010-06-01 Thread Raj Shekhar
In infinite wisdom Brent Clark wrote: > All servers are in datacentres. Im not 100% sure if its latency related, > but I see a load or SLEEP when I do mysqladin proc, which appears to be > hogging mysql. > > My question is. Would adjusting timeout values address this problem. The main causes

Re: using a count function

2010-05-29 Thread mos
Chris, You are using Count when you should be using Sum. Here is a solution you can try: SELECT SUM(IF(DATEDIFF(dateofinterview,dateofbirth)/365.25 BETWEEN 0 AND 18.999, 1,0)) AS "18 and Under", SUM(IF(DATEDIFF(dateofinterview,dateofbirth)/365.25 BETWEEN 19 A

using a count function

2010-05-29 Thread Chris Elhardt
single line of three columns, each with a count of the number of interviews for that reporting period: || Under 18 ||19-65 || over 65 || ||5|| 19|| 23 || I've made three queries to select the counts for each age range,

High MySQL sleep count

2010-05-26 Thread Brent Clark
Hiya I have a server that gets connections / requests from Germany and South Africa, Johannesburg (my server's based in Cape Town). All servers are in datacentres. Im not 100% sure if its latency related, but I see a load or SLEEP when I do mysqladin proc, which appears to be hogging mysql.

Re: C API Function for count(*)

2010-05-15 Thread Tim Johnson
* Bob Cole [100515 06:58]: > You might get closer to what you want if you put your command in a text file > and run it from the command line. > On a Mac OS X, I put a similar command: > select count(*) from testTable; > into a small text file: > testCount.txt >

Re: C API Function for count(*)

2010-05-15 Thread Tim Johnson
* Dan Nelson [100514 21:38]: > > You can't do it with one function call, but you can do it, since the MySQL > cli was able to print "16" in your example above, and it was written in C. > Take a look at mysql_store_result(), mysql_num_fields(), > mysql_field_count(), mysql_fetch_row(), and mysql_

Re: C API Function for count(*)

2010-05-15 Thread Bob Cole
You might get closer to what you want if you put your command in a text file and run it from the command line. On a Mac OS X, I put a similar command: select count(*) from testTable; into a small text file: testCount.txt and ran this command from the Terminal: mysql -u username

Re: C API Function for count(*)

2010-05-14 Thread Dan Nelson
from the system MySQL shared object. > > If I were to issue a count(*) query from my monitor interface: > Example: > mysql> select count(*) from clients; > +--+ > | count(*) | > +--+ > | 16 | > +--+ > > If "select count(*) from c

C API Function for count(*)

2010-05-14 Thread Tim Johnson
I have MySQL version 5.0.84 on linux slackware 13.0 32-bit. I am working with a relatively new API written in a programming language with a small user base (newlisp). The newlisp API imports a number of C API functions from the system MySQL shared object. If I were to issue a count(*) query

RE: Count Query question

2010-05-13 Thread webmaster
ifang -Original Message- From: Keith Clark [mailto:keithcl...@k-wbookworm.com] Sent: 13 May 2010 14:11 To: mysql@lists.mysql.com Subject: Re: Count Query question Bob, Here are a few rows of my data: 17462, 0, '0929998596', '/GraphicNovels/0929998596.jpg', '8.5000

Re: Count Query question

2010-05-13 Thread Keith Clark
x27;1561481912', '/Cooking/1561481912.jpg', '3.', '2010-05-12 19:00:17', '2008-10-01 00:00:00', '2008-10-01 00:00:00', '0.50', 1, 1, 7428, 0, '1', Here is the query I ran: SELECT date(products_date_availab

Re: Count Query question

2010-05-12 Thread Bob Cole
0 33 2010-05-08 3 33 2010-05-09 3 33 2010-05-10 0 33 2010-05-11 3 33 2010-05-12 3 and used the following query: SELECT products_date_available, COUNT(products_quantity), SUM(products_quantity) FROM products WHERE products_quantity

Re: Count Query question

2010-05-12 Thread Keith Clark
Hi Bob, No, actually it does not. I'm looking for the count of items. From your query example I only get two rows. This table has over 2 1/2 years of daily sales data. Maybe I'm not stating my question correctly...h Thanks for responding though, greatly appreciated. Kei

Re: Count Query question

2010-05-12 Thread Bob Cole
Keith: Does this work? SELECT products_date_available, COUNT(products_quantity) FROM products WHERE products_quantity > 0 GROUP BY products_date_available Hope this helps, Bob On May 12, 2010, at 3:06 PM, Keith Clark wrote: > On Wed, 2010-05-12 at 10:13 -0400, Keith

Re: Count Query question

2010-05-12 Thread Keith Clark
_added`), > KEY `manufacturers_id` (`manufacturers_id`) > ) ENGINE=MyISAM AUTO_INCREMENT=17418 DEFAULT CHARSET=latin1 > > So, I'd like to create a report that grouped by products_date_available, > counts all records before products_date_available with a > products_quantity>

Re: Count Query question

2010-05-12 Thread Keith Clark
Chris, Here is my full table definition: CREATE TABLE `products` ( `products_id` int(15) NOT NULL AUTO_INCREMENT, `products_quantity` int(4) NOT NULL, `products_model` varchar(15) NOT NULL DEFAULT '', `products_image` varchar(64) DEFAULT NULL, `products_price` decimal(15,4) DEFAULT NULL, `p

Re: Count Query question

2010-05-12 Thread Chris W
With out the table definitions, I'm not sure how anyone could help. Can you send the output of "show create table" for each of the tables involved in this query? Chris W Keith Clark wrote: I'm trying to produce a report that will tell me how many products were available with a Quantity>0 bef

Count Query question

2010-05-12 Thread Keith Clark
I'm trying to produce a report that will tell me how many products were available with a Quantity>0 before a certain date, and have that ordered by date. Table: Date Quantity Result desired DateQuantity Available May 1 5000 May 2 5050 May 3 5075 Thanks, Keith -- MySQL General Ma

Get count of number of lines from mysql stored procedure

2010-02-17 Thread Manasi Save
Hi All,I want to find out number of lines are there in all stored procedure written.Is it possible to get the number of lines using a SQL query.Thanks in advance. -- Regards, Manasi Save

Re: count children nodes

2010-02-17 Thread David Arroyo Menendez
Thanks! 2010/2/16 Peter Brawley > David, > > >I need count the messages don'tread in a thread. > > Have a look at the edge list examples at > http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. > > PB > > - > > David Arroyo Menend

Re: count children nodes

2010-02-16 Thread Peter Brawley
David, I need count the messages don'tread in a thread. Have a look at the edge list examples at http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. PB - David Arroyo Menendez wrote: Hello, I've the next table structure: CREATE TABLE tx_cc20_mensajes (

RE: count children nodes

2010-02-16 Thread Gavin Towey
Menendez [mailto:david.arr...@bbvaglobalnet.com] Sent: Tuesday, February 16, 2010 8:27 AM To: mysql@lists.mysql.com Subject: count children nodes Hello, I've the next table structure: CREATE TABLE tx_cc20_mensajes ( uid int(11) NOT NULL auto_increment, pid int(11) DEFAULT '0

count children nodes

2010-02-16 Thread David Arroyo Menendez
mensaje text, leido tinyint(3) DEFAULT '0' NOT NULL, PRIMARY KEY (uid), KEY parent (pid) ); Where padre is the id of the parent message. I need count the messages don't read in a thread. How can I do it? With $query="select count(*) as num from tx_cc20_mensajes m

Re: Count records in join

2009-12-16 Thread Miguel Vaz
Yes, that would do what you mentioned, show all programs with a count on events, but i need the opposite, show (and delete) all that dont have any events. Well, just have to use IS NULL instead. Thanks. MV On Wed, Dec 16, 2009 at 3:17 PM, Jerry Schwartz wrote: > >-Original M

RE: Count records in join

2009-12-16 Thread Jerry Schwartz
>-Original Message- >From: Miguel Vaz [mailto:pagong...@gmail.com] >Sent: Wednesday, December 16, 2009 9:39 AM >To: Johan De Meersman >Cc: Gavin Towey; mysql@lists.mysql.com >Subject: Re: Count records in join > >Thanks all for the feedback. Here's what i d

Re: Count records in join

2009-12-16 Thread Miguel Vaz
Thanks all for the feedback. Here's what i did: select p.id_prog,count(r.id_event) e from programas p left join(events r) on(p.id_prog=r.id_prog) group by r.id_event This gives me a list of all the distinct progs with a count of how many events on each. I then delete the empty ones. It wou

Re: Count records in join

2009-12-16 Thread Johan De Meersman
se. > > Regards, > Gavin Towey > > -Original Message- > From: Miguel Vaz [mailto:pagong...@gmail.com] > Sent: Tuesday, December 15, 2009 10:43 AM > To: mysql@lists.mysql.com > Subject: Count records in join > > Hi, > > I am stuck with a suposedly simple qu

RE: Count records in join

2009-12-15 Thread Gavin Towey
l Vaz [mailto:pagong...@gmail.com] Sent: Tuesday, December 15, 2009 10:43 AM To: mysql@lists.mysql.com Subject: Count records in join Hi, I am stuck with a suposedly simple query: - i have two tables (: PROGS id_prog name EVENTS id id_prog name How can i list all records from PROGS with a sum o

Count records in join

2009-12-15 Thread Miguel Vaz
Hi, I am stuck with a suposedly simple query: - i have two tables (: PROGS id_prog name EVENTS id id_prog name How can i list all records from PROGS with a sum of how many events each have? I want to find the progs that are empty. I remember something about using NULL, but i cant remember. :-

Re: COUNT from 2 tables

2009-07-08 Thread b
On 07/08/2009 06:11 PM, Gary Smith wrote: Create a view or sub select, denormalizing the data and then group it. select month, sum(login) as num_logins, sum(download) as num_downloads from ( select monthname(s.created) as month_name , if(ifnull(s.id, 0)> 0, 1, 0) as login , if(ifnull(d.id, 0)>

RE: COUNT from 2 tables

2009-07-08 Thread Gary Smith
listed first (I could be wrong though -- chime in if you know the definitive answer please). Anyway, try this and see if it gets you closer. From: b [my...@logi.ca] Sent: Wednesday, July 08, 2009 12:55 PM To: mysql@lists.mysql.com Subject: Re: COUNT from 2

Re: COUNT from 2 tables

2009-07-08 Thread b
On 07/08/2009 03:33 PM, Gary Smith wrote: Off the top of my head, try this. SELECT MONTHNAME(s.created) AS month, sum(if(ifnull(s.id,0)> 0, 1, 0)) AS num_logins, sim(if(ifnull(d.id, 0)> 0, 1, 0)) AS num_downloads FROM sessions AS s LEFT JOIN downloads AS d ON d.session_id = s.id GROUP BY month

RE: COUNT from 2 tables

2009-07-08 Thread Gary Smith
month From: b [my...@logi.ca] Sent: Wednesday, July 08, 2009 12:21 PM To: mysql@lists.mysql.com Subject: COUNT from 2 tables I'm trying to get a count for columns in 2 tables at once. I have sessions and downloads tables and would like to get some basic stats. mysql> des

COUNT from 2 tables

2009-07-08 Thread b
I'm trying to get a count for columns in 2 tables at once. I have sessions and downloads tables and would like to get some basic stats. mysql> describe sessions; +-+--+--+-+-++ | Field | Type | Null | Key | Default

AW: why different users get different count(*) from same table?

2009-07-01 Thread Benedikt Schackenberg
Check your rights ;) -Ursprüngliche Nachricht- Von: jinava [mailto:jin...@gmail.com] Gesendet: Mittwoch, 1. Juli 2009 14:52 An: mysql@lists.mysql.com Betreff: Re: why different users get different count(*) from same table? Hi experts, Something strange here, use root and mysql (root

Re: why different users get different count(*) from same table?

2009-07-01 Thread jinava
Hi experts, Something strange here, use root and mysql (root and mysql are user accounts) to select count(*) from same table, but the result is different. login as root: mysql -uroot -p information_schema mysql> select * from tables where table_name='tb_staff'\G

why different users get different count(*) from same table?

2009-06-29 Thread jinava
Hi experts, something strange here, use root and mysql (root and mysql are user accounts) to select count(*) from same table, but the result is different. login as root: mysql -uroot -p information_schema mysql> select * from tables where table_name='tb_staff'\G

Re: Two "COUNT"s in one query

2009-04-23 Thread Nigel Peck
Thanks to everyone who helped me out with this, just what I needed and this is now working for me. One further question... I'm using a subquery as suggested: SELECT `Organisations`.`organisation_id`, `Organisations`.`name`, (SELECT COUNT(*) FROM `Notes__Organisations`

Re: Two "COUNT"s in one query

2009-04-21 Thread Peter Brawley
Nigel, >I want to select the name and id from "Organisations" >along with a count of the number of one-to-many >relationships it has in each of the two tables. Aggregation multiplies across multiple joins. For suggested solutions see "Aggregates across

Two "COUNT"s in one query

2009-04-21 Thread Nigel Peck
Notes__Organisations" and "Organisations__People". I want to select the name and id from "Organisations" along with a count of the number of one-to-many relationships it has in each of the two tables. I want a count of 0 if there are none, so I'm using two LEFT JOINs and

RE: Left join does not work with Count() as expected

2009-02-19 Thread Martin Gainty
= t2.a); +--+--+--+--+ | a| b| a| c| +--+--+--+--+ |1 | x| NULL | NULL | |2 | y|2 | z| +--+--+--+--+ (Row1 is included but 3 is leftout because it doesnt have a corresponding row in t1) Your query SELECT forums.id ,

Re: Left join does not work with Count() as expected

2009-02-19 Thread Peter Brawley
>SELECT forums.id , COUNT( forum_msg.id ) AS cnt >FROM forums >LEFT JOIN forum_msg ON forums.id = forum_msg.forum_id >ORDER BY forums.sorder ASC Missing GROUP BY. PB - Artem Kuchin wrote: I have two simple tables. One - list of forums, second - list of messages and i want

Re: Left join does not work with Count() as expected

2009-02-19 Thread Olaf Stein
You need to group by forum_id... On 2/19/09 11:09 AM, "Artem Kuchin" wrote: > I have two simple tables. One - list of forums, second - list of > messages and i want to > get the list of forums with number of messages in each. > > Here is the query: > > SELECT

Left join does not work with Count() as expected

2009-02-19 Thread Artem Kuchin
I have two simple tables. One - list of forums, second - list of messages and i want to get the list of forums with number of messages in each. Here is the query: SELECT forums.id , COUNT( forum_msg.id ) AS cnt FROM forums LEFT JOIN forum_msg ON forums.id = forum_msg.forum_id ORDER BY

  1   2   3   4   5   6   7   8   9   10   >