RE: Aggregate

2012-09-22 Thread hsv
2012/09/04 11:43 -0700, Rick James int(1) does not mean what you think. Probably you want TINYINT UNSIGNED. Yeap, a real misfeature of MySQL. It is also one of the ways wherin MySQL puts in C and takes PL1 away. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql

RE: Aggregate

2012-09-05 Thread hsv
2012/09/04 11:43 -0700, Rick James You have DATETIME and TIMESTAMP. Keep in mind that TIMEZONE is timezone-aware; DATETIME is not. TIMEZONE is typo for TIMESTAMP? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

RE: Aggregate

2012-09-04 Thread Rick James
int(1) does not mean what you think. Probably you want TINYINT UNSIGNED. int(25), bigint(250) -- Eh? INT is always 4 bytes (32-bits); BIGINT is always 8 bytes. Use UNSIGNED wherever appropriate. You have DATETIME and TIMESTAMP. Keep in mind that TIMEZONE is timezone-aware; DATETIME is not.

Re: Aggregate Function Help (first and last records)

2006-08-04 Thread Michael Caplan
I just noticed that MSAccess and SQL server support FIRST() and LAST() functions. Is there an equivalent in MySQL? My research has come up with nil so far. Thanks, Michael Michael Caplan wrote: Hi there, I am trying to figure out how to flatten the result set of a join query using

Re: Aggregate Function Help (first and last records)

2006-08-04 Thread Michael Caplan
Thanks Nestor, I thought about that, but limit 1 doesn't work in my scenario as I want to access both the FIRST() and LAST() column for a result set simultaneously. By telling MySQL to limit to 1, I could get the first, but not the last. I want mysql to give me the first, drop everything in

Re: Aggregate Function Help (first and last records)

2006-08-04 Thread Michael Caplan
Thanks Nestor! I think I am almost there. However, how can I limit the result of a JOIN in a query, and not the entire result set? For example: SELECT * FROM a JOIN b ON a.id = b.id If I wanted all records from a and only the first record from b, how would I integrate a LIMIT

RE: Aggregate functions in ORDER BY

2006-03-09 Thread Dave Pullin
PROTECTED] Sent: Wednesday, March 08, 2006 11:10 PM To: Dave Pullin Cc: mysql@lists.mysql.com Subject: Re: Aggregate functions in ORDER BY Many thanks for that Dave. Do you know whether it's possible for MySQL to return fully qualified column names by default? For example, I'd like

Re: Aggregate functions in ORDER BY

2006-03-09 Thread Yasir Assam
11:10 PM To: Dave Pullin Cc: mysql@lists.mysql.com Subject: Re: Aggregate functions in ORDER BY Many thanks for that Dave. Do you know whether it's possible for MySQL to return fully qualified column names by default? For example, I'd like select * from foo; to return

Re: Aggregate functions in ORDER BY

2006-03-09 Thread Yasir Assam
Thanks for that Nicolas. Yasir Can you run without the Order By at all? If not, you may need to properly join the tables. I could reproduce the issue with MySQL 4.1 as well and I would go around it myself by creating a temporaty table, populating it with the aggregate, doing a select on the

RE: Aggregate functions in ORDER BY

2006-03-08 Thread Dave Pullin
All you are doing when you quote the expression like `COUNT(pets.pet_id)` is referencing the column in the select by its default column name (which is the same as the expression.) That's why it only works when the expression is a column. If you dont want the order by column to appear in the

Re: Aggregate functions in ORDER BY

2006-03-08 Thread Yasir Assam
Many thanks for that Dave. Do you know whether it's possible for MySQL to return fully qualified column names by default? For example, I'd like select * from foo; to return ++--+ | foo.a | foo.b| ++--+ | 1 | Rex | | 2 | Buddy| |

RE: Aggregate functions in ORDER BY

2006-03-08 Thread Nicolas Verhaeghe
Can you run without the Order By at all? If not, you may need to properly join the tables. I could reproduce the issue with MySQL 4.1 as well and I would go around it myself by creating a temporaty table, populating it with the aggregate, doing a select on the temp table and then of course

Re: aggregate count and group by

2005-02-25 Thread Jim Grill
Jim Grill [EMAIL PROTECTED] wrote on 02/18/2005 03:17:39 PM: Hi, I need some SQL guru help on this one. I'm trying to re factor an existing application where a number of clicks grouped by keyword for two different time periods are needed. For example, a user picks a date range and the

Re: aggregate count and group by

2005-02-22 Thread SGreen
Jim Grill [EMAIL PROTECTED] wrote on 02/18/2005 03:17:39 PM: Hi, I need some SQL guru help on this one. I'm trying to re factor an existing application where a number of clicks grouped by keyword for two different time periods are needed. For example, a user picks a date range and

RE: aggregate functions producing bad data

2002-09-18 Thread Gerben Gieling
Perhaps you should create a new table with an id column and a flag column. Select the found calls 5 or = 5 into that new table and set the flag. Then do a left join of your t_callog_calls table on the new table selecting only the rows where the flag is NULL, these should be the rows not found by

re: Re: aggregate functions producing bad data

2002-09-18 Thread Victoria Reznichenko
Jay, Tuesday, September 17, 2002, 10:45:51 PM, you wrote: J On my server the MySQL database decided to die on me. So I killed it and J restarted and that didn't work. So I just rebooted the machine. Now I'm J getting this error below. J Invalid SQL: SELECT COUNT(*) AS messages FROM

Re: aggregate functions producing bad data

2002-09-17 Thread Brian Reichert
On Tue, Sep 17, 2002 at 11:59:42AM -0700, Richard Unger wrote: My query: SELECT count(id), count( IF(call_end - call_start 5, id, NULL) ), count( IF(call_end - call_start = 5, id, NULL) ) FROM t_calllog_calls; My result: 1994 1956 35 However, 1956

Re: aggregate functions producing bad data

2002-09-17 Thread Gelu Gogancea
Hi, I think you should try to use 0 instead of NULL Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Richard

RE: aggregate functions producing bad data

2002-09-17 Thread Richard Unger
I _thought_ it was the fault of the aggregate function, but now I'm really confused! When I produce them as 3 separate queries, I still get numbers that don't add up: mysql select count(id) from t_calllog_calls; +---+ | count(id) | +---+ | 1994 | +---+ 1 row in set

RE: aggregate functions producing bad data

2002-09-17 Thread Richard Unger
, September 17, 2002 12:08 PM To: Richard Unger; [EMAIL PROTECTED] Subject: Re: aggregate functions producing bad data Hi, I think you should try to use 0 instead of NULL Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address

RE: aggregate functions producing bad data

2002-09-17 Thread Richard Unger
id is the primary key. There are no entries in the DB where id=NULL Cheers, Rich -Original Message- From: Brian Reichert [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 12:16 PM To: Richard Unger Cc: [EMAIL PROTECTED] Subject: Re: aggregate functions producing bad

Re: aggregate functions producing bad data

2002-09-17 Thread Dan Nelson
In the last episode (Sep 17), Brian Reichert said: On Tue, Sep 17, 2002 at 11:59:42AM -0700, Richard Unger wrote: My query: SELECT count(id), count( IF(call_end - call_start 5, id, NULL) ), count( IF(call_end - call_start = 5, id, NULL) ) FROM

RE: aggregate functions producing bad data

2002-09-17 Thread mtoth
of calls. Cheers, Rich -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 12:08 PM To: Richard Unger; [EMAIL PROTECTED] Subject: Re: aggregate functions producing bad data Hi, I think you should try to use 0 instead

RE: aggregate functions producing bad data

2002-09-17 Thread Richard Unger
-Original Message- From: Dan Nelson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 12:31 PM To: Brian Reichert Cc: Richard Unger; [EMAIL PROTECTED] Subject: Re: aggregate functions producing bad data In the last episode (Sep 17), Brian Reichert said: On Tue, Sep

RE: aggregate functions producing bad data

2002-09-17 Thread Richard Unger
: [EMAIL PROTECTED] Subject: RE: aggregate functions producing bad data what does Select count(id) from t_calllog_calls where id IS NULL give you? On Tue, 17 Sep 2002, Richard Unger wrote: That would just give me 1994 for all 3 columns of output. What I want to know is how many calls

Re: aggregate functions producing bad data

2002-09-17 Thread Jay
On my server the MySQL database decided to die on me. So I killed it and restarted and that didn't work. So I just rebooted the machine. Now I'm getting this error below. Invalid SQL: SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=1 mysql error: Can't open file:

Re: aggregate functions producing bad data

2002-09-17 Thread Gelu Gogancea
] - Original Message - From: Brian Reichert [EMAIL PROTECTED] To: Richard Unger [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, September 17, 2002 10:16 PM Subject: Re: aggregate functions producing bad data On Tue, Sep 17, 2002 at 11:59:42AM -0700, Richard Unger wrote: My query: SELECT

Re: aggregate functions producing bad data

2002-09-17 Thread Gelu Gogancea
PROTECTED] [EMAIL PROTECTED] - Original Message - From: Brian Reichert [EMAIL PROTECTED] To: Richard Unger [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, September 17, 2002 10:16 PM Subject: Re: aggregate functions producing bad data On Tue, Sep

Re: aggregate functions producing bad data

2002-09-17 Thread mtoth
, September 17, 2002 10:16 PM Subject: Re: aggregate functions producing bad data On Tue, Sep 17, 2002 at 11:59:42AM -0700, Richard Unger wrote: My query: SELECT count(id), count( IF(call_end - call_start 5, id, NULL) ), count( IF(call_end - call_start = 5, id, NULL) ) FROM

Re: aggregate functions producing bad data

2002-09-17 Thread Benjamin Pflugmann
Hi. Could you run the following query: SELECTIF(call_end - call_start 5, id, NULL) AS long, IF(call_end - call_start = 5, id, NULL) AS short, COUNT(*) FROM t_calllog_calls GROUP BY long, short Given that I have not made any mistake, that should list all rows

Re: Aggregate functions

2002-06-07 Thread Egor Egorov
Kris, Friday, June 07, 2002, 1:21:48 PM, you wrote: KS Sorry to bother the Guru's here, but I've recently started working on KS getting a mySQL database up and running and I noticed that some KS aggregate functions like MAX and MIN don't have 'DISTINCT' as an KS optional arguement. Are these not

RE: Aggregate Functions - Count, Sum

2001-07-11 Thread Don Read
On 11-Jul-01 Nelson Goforth wrote: I'm trying to return several pieces of information from a small table. Table is 'tickets': idCHAR(50) group CHAR(50) issuedDATE used DATE 'issued' and 'used' are NULL until a date is entered. The found set is

RE: Aggregate Functions - Count, Sum

2001-07-11 Thread Nelson Goforth
Don, thank you. The SELECT statement worked perfectly just as you suggested. Though the books I have on MySQL are pretty good, trying to figure more and more esoteric statements out is a bit of a challenge, even just in terms of syntax. Nelson In looking via SELECT * FROM tickets, the

Re: Aggregate string values

2001-05-04 Thread Thalis A. Kalfigopoulos
On Fri, 4 May 2001, Joel Desamero wrote: Hello, I was wondering if there is a way to aggregate string values when grouping together results. I guess what I'm looking for is the string version of the SUM() function. Is there such a thing in MySQL? Thanks. No. You could write your UDF

Re: aggregate UDF's

2001-02-23 Thread Sinisa Milivojevic
Jeremy D. Zawodny writes: On Thu, Feb 22, 2001 at 12:39:41AM +0100, michi platzer wrote: i need to write my own very basic aggregate functions for MySQL and had a couple of questions regarding this: * does anybody know of a site with a collection of UDF's written by other