max

Sql query to find MAx row in subqury

Hi All. These are my tables:User,Product,DiscountGroup,DiscountUser,DiscountProduct. DiscountProduct: id discountGroupId productId discount --- -------------- --------- ------- 1 2 8 2000 2 3 8 1000 3 2 4 4500 Dis...

MySQL need help.. how can I filter max(date)

i have a table assumed like this [table a] UID | UNAME ------------------ 001 | a 002 | b 003 | c [table b] UID | LOGS ---------------------- 001 | 2009/08/01 001 | 2009/08/03 003 | 2009/08/02 and i want to have a query like this UID | LASTLOG -------------------- 001 | 2009/08...

No max(x,y) function in Access

Can someone explain to me how VBA for Access could ship without a simple Max(x,y) Function? I know it can be done: IIf(x > y, x,y) but really... why? ...

NetCdf: how to obtain min and max for variable

NetCdf: For a grid you can obtain the minimum and maximum value for data in the following way: MAMath.MinMax dataMinMax = grid.getMinMaxSkipMissingData( data); float min = (float) (dataMinMax.min); float max = (float) (dataMinMax.max); but what if you just have a ucar.nc2.Variable. Can you also obtain this kind of information? Kind reg...

Max number of transactions in MSMQ

We are planning to use MSMQ transaction in one of our application. I am not sure what is the maximum number of transaction we can have for MSMQ? ...

Mathematically Find Max Value without Conditional Comparison

----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right shift I divided by 29. Because with 32bits signed 2^31 = overflows to 29. Which works! Prototype in PHP $r = $x - (($x - $y) & (($x - $y) / (29))); Actual code for LEADS...

How might I find the largest number contained in a JavaScript array?

I have a simple JavaScript Array object containing a few numbers. [267, 306, 108] Is there a function that would find the largest number in this array? ...

MySQL MAX() and NULLs

Hi, I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM timesheet GROUP BY weekEnd The valid values for timeMonday are: null, -1, 0, 1-24. At the moment, MAX() places the preference of those values in the order null, -1, 0, 1-24, however what I actually want is -1, null, 0, 1-24, so that null is considered...

Javascript max() function for 3 numbers

I need to find the highest number from 3 different numbers. The only thing I've found is max() but you can only use 2 numbers. Whats the best way? ...

Select latest revision of each row in a table

I have table structures that include a composite primary key of id & revision where both are integers. I need a query that will return the latest revision of each row. If I understood this answer correctly then the following would have worked on an Oracle DB. SELECT Id, Title FROM ( SELECT Id, Revision, MAX(Revision) OVER (PARTITION BY...

SQL max and null

I am trying to get the null value in the USAGE_START_DATE column. So far, what is i got is the unique max records of those with value in the USAGE START DATE column, and could not find any the records with nulls in the USAGE START DATE. I already tried ISNULL, COALESCE, NVL, NZ. I got 2 tables: linked by Reservation_id. Reservation...

Select max age C#

Greetings, I created a list that contains a collection of objects that have this properties: X, Y, Z I want to find out which object in the collection has the greatest Z I tried to use the Max() function but I don't understand how it's used... How can I accomplish this Thanks in advance ...

Crazy python behaviour

I have a little piece of python code in the server script for my website which looks a little bit like this: console.append([str(x) for x in data]) console.append(str(max(data))) quite simple, you might think, however the result it's outputting is this: ['3', '12', '3'] 3 for some reason python thinks 3 is the max of [3,12,3]! So ...

How to get the max of two values in MySQL?

I tried but failed: mysql> select max(1,0); 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 '0)' at line 1 ...

Problem with MySql INSERT MAX()+1

I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1 I've prepared a simple example: Showing all names +--------------+-----------------------+ | user_id | name | +--------------+-------------------...

Need Linq translation for the following SQL Query

select colId, colTaskType, MaxID from tblTaskType join ( select tblCheckList.colTaskTypeID, max(colItemNumber) MaxID from tblCheckList group by colTaskTypeID ) x on coltaskTypeID = tblTaskType.colID ...

CSS Set maximum distance from browser edge.

I've got my site content inside an 800px-wide div, I'd like that div to be centered on the page until the browser window width extends past certain distance. At that point, I'd like the content to "lock" into place and not continue to center itself, staying a fixed amount from the left edge. For example, if the viewers window is 900px w...

Fastest way to zero out low values in array?

So, lets say I have 100,000 float arrays with 100 elements each. I need the highest X number of values, BUT only if they are greater than Y. Any element not matching this should be set to 0. What would be the fastest way to do this in Python? Order must be maintained. Most of the elements are already set to 0. sample variables: a...

Use of min and max functions in C++

From C++, are min and max preferable over fmin and fmax? For comparing two integers, do they provide basically the same functionality? Do you tend to use one of these sets of functions or do you prefer to write your own (perhaps to improve efficiency, portability, flexibility, etc.)? Notes: The C++ Standard Template Library (STL) d...

How to get the greatest of two columns values in MySQL?

I'm trying to do something like this: SELECT MAX( ADDDATE(expirationdate, INTERVAL 1 YEAR), ADDDATE(now(), INTERVAL 1 YEAR) ) That is, get "a year from now", or "a year from the expiration date stored in the table", whichever is greater (i'm renewing people's subscriptions). This obviously doesn't work, since MAX() is for aggrega...