Re: Using MAX function to fetch primary id

2007-09-10 Thread Brent Baisley
You can do it as long as there is only a single record with the max value. If there is more than 1 record with the same max value, there isn't a single record to pull. To do it, you would need to join on the results of the max query, and part of the join condition would be the max value S

RE: Using MAX function to fetch primary id

2007-09-07 Thread Daevid Vincent
> -Original Message- > I need to select a max value for a group of records and I > also need the > primary key for that record. > > I am wondering if this can be done with a single query? e.g > > Table_x > > id count cat_id > 110 1 > 220 2 > 335

Using MAX function to fetch primary id

2007-09-07 Thread Cathy Fusko
Hi, I need to select a max value for a group of records and I also need the primary key for that record. I am wondering if this can be done with a single query? e.g Table_x id count cat_id 110 1 220 2 335 2 415 1 with SELECT id, cat_id, max

max function

2002-03-07 Thread Manish Mehta
Hi I got a problem with max function select a.cemp_firstname,sum(nsalary_value),max(nsalary_status),max(dstatus_date) from employeemaster as a,empsal as s where a.nemp_id = s.nemp_id group by dstatus_date This query shows me two records . But my requriment is according to the max -> sal

Re: extra max() function possibly very useful?

2002-03-05 Thread Michael Widenius
Hi! > "Richard" == Richard Clarke <[EMAIL PROTECTED]> writes: Richard> Because that wouldn't give the correct results. Richard> I want the top 5 rows for EACH id. Richard> A short example would be, Richard> mytable: Richard> IdValHits Richard> 1 a 10 Richard> 1 b

Fw: extra max() function possibly very useful?

2002-03-04 Thread DL Neil
ist'. > > Regards, > =dn > > - Original Message - > From: "Richard Clarke" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: 04 March 2002 19:09 > Subject: Re: extra max() function possibly very useful? > > > > Cor

Re: extra max() function possibly very useful?

2002-03-04 Thread DL Neil
ge - From: "Richard Clarke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: 04 March 2002 19:09 Subject: Re: extra max() function possibly very useful? > Correct. > > Richard > > > - Original Message - > From: "DL Neil" <[EMAIL PR

Re: extra max() function possibly very useful?

2002-03-04 Thread Richard Clarke
Correct. Richard - Original Message - From: "DL Neil" <[EMAIL PROTECTED]> To: "Richard Clarke" <[EMAIL PROTECTED]>; "Christopher Thompson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, March 04, 2002 6:34 PM Subject: Re: e

Re: extra max() function possibly very useful?

2002-03-04 Thread Richard Clarke
t; <[EMAIL PROTECTED]> To: "Richard Clarke" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, March 04, 2002 5:56 PM Subject: Re: extra max() function possibly very useful? > On Monday 04 March 2002 10:50 am, Richard Clarke wrote: > > > > create t

Re: extra max() function possibly very useful?

2002-03-04 Thread Christopher Thompson
On Monday 04 March 2002 10:50 am, Richard Clarke wrote: > > create table mytable (id int, val char(255), hits int); > insert some data... > > select max(5,hits) from mytable group by id; > > This would allow selecting of the top 5 rows for each id according to the > hit column. > > Without this fu

extra max() function possibly very useful?

2002-03-04 Thread Richard Clarke
Hi, What would the plausability of a function like this being implemented in the future. create table mytable (id int, val char(255), hits int); insert some data... select max(5,hits) from mytable group by id; This would allow selecting of the top 5 rows for each id according to the hit column

Embedded max() function in an insert?

2001-08-08 Thread Jason Ziegler
All, Is there any way to do the following in MySQL: INSERT INTO TableName (rowID) VALUES ('max(rowID)+1') (so that the next unique identifier for the table can be determined WITHIN the insert statement?) I know MySQL provides auto-incrementing and last_insert_id. However, architecture constrai