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
> -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
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
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
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
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
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
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
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
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
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
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
12 matches
Mail list logo