FAQ Database Discussion Community


confused about max() built in function

python,max
hello I am kind of confused about the max() function, I have the following code: a = '9:30' b = '10:44' c = '8:22' x = max(a, b, c) print (x) so my question is: why does this return 9:30? and if I were to delete the a from inside...

SELECT DISTINCT user_id of highest value in support_date WHERE

mysql,sql-order-by,max,distinct,where
tb_supporters: user_id support_date ----------------------------- 1 1301283373 2 1301283743 3 1301799207 1 1403862904 2 1405174895 3 1415266390 As the result of the query, it should output the highest support_date of each unique user_id. My actual query: "SELECT DISTINCT(user_id), support_date FROM tb_supporters WHERE support_date < " . (time() - 60*60*24*7) However, it's...

MAX and GROUP BY - SQL

sql,oracle,max
I'm working on Oracle SQL and HR database, I'm trying to select maximum salary in department like this: SELECT MAX(salary), department_id FROM employees GROUP BY department_id; It works fine, but I want to know >who< is earning the most, so I simply change query this way: SELECT first_name, last_name, MAX(salary),...

SQL use MAX() function select field not in Group By

sql,ms-access,group-by,max
I want to find the most recent entry for a unique combination of two fields in my table. Employee_Number | Cap_Id | Score | Date_Added I want to find the most recent 'Date_Added' for a group of Employee_Number and Cap_Id but also show the 'Score' entered for that group. I...

C++ Increase int size limit

c++,int,size,max
Is there a way in C++ to increase the limit on integers? I want to work with a 13 digit number e.g. 4823423658586. The complier does not allow this.

BiqQuery - select values with max function

sql,max,google-bigquery
I have this kind of table (just for example.. in my case this table has over 60000 records) I would like to know how to make a select to get which gender rate a movieId (or songId) with higher rate? I do query like this: select * from ( SELECT...

MySQL Group By - Get row associated with max() amount

mysql,group-by,max
What I am trying to get is the row contents containing the highest price. I am not sure if I need to self-join, or use a having statement. Most of the attempts I have tried netted me no returned rows. Effectively I want to say "WHERE PRICE IS MAX". I...

How to find most expensive items in sql with more than one most expensive item?

mysql,sqlite,max
I have more than one items with the highest price on my database and I would like to know how to return the most expensive items with the highest price on my database, without using LIMIT. I have tried using SELECT MAX(price) FROM items but it only returns one item...

R- min and max on a row, defined to a number of columns

r,max,average,minimum
I have 4 variables, each in triplicates, and I need to find the average for each triplicate, in each row, and on top of that find minimum and maximum for each 5th row, in order to plot error bars. Here is an example with two variables: x a1 a2 a3...

sql: show only the max count (php)

php,html,sql,count,max
I have been scrolling through various examples but can't seem to get the right answer. What I am trying to get here is to display: staffID,name from Table Staff total no. of tasks that the staff is involved in from StaffWorksInTask (Only with the staff that is involved with most...

C++ How can I use the max() function with an array? [duplicate]

c++,arrays,max
This question already has an answer here: Finding the highest number in an array C++ 5 answers I have an array of integers that has 18 values. I need to find which one of them is the largest. I tried like this: FinalValue = max(values); However, it had an...

Put several intengers into a list to get the maximum number

python,list,max
I'm really new to Python but I have a question, that I can't answer with google oder stackoverlow. Mainly because I don't know what to type into the search field as "integers into list" does not get me the result I want... My problem is the following. I have a...

ElasticSearch aggregation - get the exact time of a max histogram value in a timeseries

java,elasticsearch,max,histogram,aggregation
I am quite new to elasticsearch, so apologies if this is a trivial question. I have a time series with irregular updates every n number of seconds that I want to plot historically. The data contains a long variable called 'score', and a long variable with the epoch called 'time'...

Max and min in Scheme

scheme,max,racket,min
I need to get the max and min of a list in scheme. I have the whole code but there is something wrong. I am not sure what, maybe with the parenthesis. Can anyone help? #lang racket (define (maxmin L) (cond ((null? L) '()) ((null? (cdr L)) (list (car L)...

sql - Why doesn't MAX() of SUM() work?

mysql,sql,sum,max
I am trying to understand why the SQL command of MAX(SUM(col)) gives the a syntax error. I have the two tables as below-: +--------+--------+---------+-------+ | pname | rollno | address | score | +--------+--------+---------+-------+ | A | 1 | CCU | 1234 | | B | 2 | CCU |...

Find the dept that is being paid the max salary

mysql,sql,database,max
I'm a student and am working on a MySql assignment given to us for the holidays. I have a table that looks something like this : name dept salary A Sales 100 B Marketing 200 C Sales 800 (Sorry I'm new to stackexchange so I don't know how to display...

Why does max (Operator) not return the longest list?

f#,max
I want to find the longest of two lists. Consider the following code sample: let xs = ['B'] let ys = ['A'; 'B'] let longest = max xs ys printfn "%A" longest Contrary to my expectation the output of this program is ['B'] rather than ['A'; 'B']. Why does List<'T>...

a maximum value per rowname(1, 2, or A, B..) per multiple columns in R

r,max,duplicate-data
I want to a maximum value per rowname(1, 2, or A, B..) per multiple columns(samples). I have a matrix. id sample1 sample2 sample3 ... 1 16498 2416 12555.5 1 21282.5 3342 22202 2 18558 2308 na 2 17966 3047 na 2 398 176.5 na 3 347 227 201.5 3 604.5...

R : min and max numeric value with name

r,max,min
NAME Number cars 10 people 340 bus 4 I have to find way to rapresent minimum and maximum numeric value with his correspondent name from first coulmn. if I put command : min(data[,2]) max(data[,2]) the results are only values the final result should be displayed like : for minimum value*...

Get Max(value) without grouping in SQL Server

sql,sql-server,tsql,group-by,max
I have this grouping problem that I do not need. Here is my SQL code to create and seed the table: create table player ( playerid int identity(1,1) primary key, Name varchar(255) ) create table gameplay ( gameplayid int identity(1,1) primary key, Name varchar(255), playerid int references player(playerid) ) Create...

how to extract date and time parts from mysql max query

mysql,select,max,datepart
I need to select a max(date) from a MySQL table and have each part of the date and time be in a separate variable. Something like: select max(date) as year, month, day, hour, minute, second from table How would I do that? ...

How to find the keys of the largest values in Hash R?

r,hash,max,hashtable
I have a hash which look likes the example and I create this hash using hash package. How can I return keys of maximum values in R ? input hash table : h<-hash( keys=c(1,4,5,6),values=c(30,25,25,30) ) # <hash> containing 3 key-value pair(s). # 1 : 30 # 4 : 25 #...

Cross fading two jit.windows with opengl content

max,jit,max-msp-jitter,jitter
How can I cross fade two jit.windows? One has an OpenGL content and another is just a matrix (wab cam capture) Halp please

How to get change points in oracle select query?

sql,oracle,max,min,row-number
How can I select change points from this data set 1 0 2 0 3 0 4 100 5 100 6 100 7 100 8 0 9 0 10 0 11 100 12 100 13 0 14 0 15 0 I want this result 4 7 100 11 12 100...

displaying minimum and maximum of a vector C++

c++,vector,max,min
I have written code that outputs the total rainfall for a set amount of years. My question is how would I just display the year with the largest and smallest rainfall i.e the maximum and minimum of the dataset with the corresponding year. The output i have so far is:...

How do I set max-width for a table cell?

html,css,width,max
Look at this code: #test { width: 20%; word-break: break-all; } <table> <tr> <td id="test"> <ul> <li>HiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiBye</li> </ul> </td> <td> Box 2: Where is its 80% width? </td> </tr> </table> How do I set max width 20% for #test with a super-long string non-broken in it? If I set width...

which(vector1 < vector2)

r,max,simultaneous,which
Let's make a small example first, that computes in R: x<- c(1,3,1,4,2) max(which(x<2)) [1] 3 Now, I would like to do this not just for one value 2, but for many values simultaneously. It should give me something like that: max(which(x<c(1,2,3,4,5,6))) [1] NA 3 5 5 5 5 Of course...

Select where max date

sql,sql-server,select,max
I want to select the last note from notes with the following query: SELECT cn.Note, MAX(cn.Date) FROM CarsNote cn WHERE CustomerID = '80' AND cn.Type = 'INFO' GROUP BY Note When I execute this query i get four results but i want only the last note. When i do SELECT...

how to unique a data frame by the values in a specified column?

r,max,group
I have a data frame in R with columns "name" and "length". The "name" is not unique and the same "name" repeats several times in the data frame. But I wanted to keep only one row with the largest "length" for each "name". Which function in R can I use...

psql max group by just for some columns

sql,postgresql,select,max,psql
I have a problem in a psql query. I don't know how to select only the maximum value from a subset of two columns. It's very hard to explain the problem without an example, so I write one: I have a table like that: Athlete | Category | Points at1...

How do I store the value of the max integer in an array before repeating loop?

arrays,max
It's been a couple hours. I don't understand arrays well enough to determine the right way to save a value as max and then determine the maximum value within the array. Please help explain how to make the for loop correctly. Thanks. #include <stdio.h> #include <conio.h> #define SIZE 3 int...

How to develop a maximum and minimum heigh in a vertical layout? (SOLVED)

android,xml,layout,height,max
This code implements the design of the picture: The upper layout has a maximum height, and if it overcomes this height: a scroll bar is shown. And the bottom layout has a minimum height, and it is aligned to the bottom of the upper layout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"...

XQuery substring for a sequence of items

substring,max,xquery
I want to extract all values of a column from a table, determine the maximum of those values, and return that value. This is what I tried: let $abc := doc("file:///some_local_file")//AOSCAT_MetricDetail//table[@class="pretty-table"]//tr/td[13] return <li>{ fn:max(fn:substring($abc,1,1)) }</li> But fn:substring can't handle a sequence of more than one item. So I tried this:...

Finding the row before maximum value using R

r,max
I'm interested in finding the row before the max value in R. The dataframe looks like this: timeround n 1 01:00 11 2 02:00 6 3 03:00 4 4 04:00 4 5 05:00 7 6 06:00 22 7 07:00 63 8 08:00 142 9 09:00 155 10 10:00 220 11...

Swift Round up / Max the NSDecimalNumber

swift,max,nsdecimalnumber,roundup
Let's say we have an NSDecimal constant called total and it contains the value of 3.33333333 divided by 10/3. 10 and 3 are both NSDecimalNumber. We want the total to be 4 as an NSDecimalNumber in Swift. let total = ten/three // the ideal total would be rounded up whenever...

OpenCL barrier of finding max in a block

parallel-processing,max,opencl,gpgpu,barrier
I've found a piece of OpenCL kernel sample code in Nvidia's developer site The purpose function maxOneBlock is to find out the biggest value of array maxValue and store it to maxValue[0]. I was fully understand about the looping part, but confused about the unroll part: Why the unroll part...

Getting the max variable out of the given variables

java,variables,max
I want to find the variable having the maximum value from three variables. Im using the given code to find the maximum value, but it only can output the maxium value.I want to get the variable having the maximum value.any methods? int x=1; int y=2; int z=3; int max =...

SQLite obtain a MAX from 2 joins

sqlite,join,max
I would like to get some scores from 2 tables (tastings, ratings) join to a first table (wines). 1 wine can own multiples tastings and ratings. Structure: table wines ----------- id name table tastings ------------- id wine_id date score table ratings ------------- id wine_id date score Scenario: 1 wine has...

Create an array with the maximum of a list of arrays

python,arrays,numpy,max
I've 24 arrays in a list and I'd like to crate an array with the maximum of each index. In other words, I've something like this list_value = [array([1,2,3]), array([4,5,6]), array([7,8,9]), array([1,5,8]), array([9,4,3])] In my case, each array has 280000 values. And I would like create an array like this:...

Find the maximum of the length of 2 arrays

java,math,max,maxlength
I am passing 2 arrays to the controller with different lengths, I want to execute a for loop and length of that will be the max of the length of 2 arrays. I am not getting how to execute that. I tried Math.max but its giving me error as cannot...

Get max date with linq where condition, inside query

c#,linq,max
I have the following two tables that store the calls that the users made, Users ----- IdUser int PK, Name varchar(50) Calls ------ idCall int PK, idUser int FK, CallDate datetime This is the code i tried but i cant seem to get it to work var resultado = (from...

max-width for cell in wide table

html,css,width,max,html-table
I have a table which is very wide. Much wider than the width of the screen due to most of the columns having white-space: nowrap. I have a few "wrapping" columns with white-space: normal. These columns are squished extremely narrow. Setting width: 500px has no effect. Setting min-width: 500px forces...

Finding the complexity of a function

python,max,time-complexity,complexity-theory
I am trying to calculate the time complexity of the next function, max_list11, which finds a maximum of a list recursively: def max11(L,left,right): if left==right: return L[left] return max(L[left], max11(L,left+1,right)) def max_list11(L): return max11(L,0,len(L)-1) From what I found out, the time complexity should be O(n), since what the function does...

DAX for MAX of a group

visual-studio-2012,max,powerpivot,calculated-columns,dax
I have two data columns: Record | Record Version ------------------------ 1 | 1 1 | 2 1 | 3 2 | 1 2 | 2 2 | 3 2 | 4 3 | 1 3 | 2 3 | 3 4 | 1 4 | 2 4 | 3 4...

How to get maximum value from a column in a data.frame and get ALL records

r,data.frame,max
I have a data.frame and I wish to get the row that contains the maximum value for the given column Total Txn_date Cust_no Acct_no cust_type Credit Debit Total 09DEC2013 17382 601298644 I 1500 0 1500 16DEC2013 17382 601298644 I 500 0 500 17DEC2013 17382 601298644 I 0 60 60 18DEC2013...

SQL Server Query syntax to count maximum occurrences of a variable and output same

sql-server,max
I am using SQL Server 2014 and I have a simple query that gives me the following output if I run it against the relevant table. So here's the query: use MyDatabase select ReservationStayID , NonRoomBundleID ,StayDate from ResStayNonRoomBundle where ReservationStayID = 11676 Output is as follows: ReservationStayID NonRoomBundleID StayDate...

Merge two matrix and find the maximum of its attributes

matlab,matrix,max,cell-array
I've two matrix a and b and I'd like to combine the rows in a way that in the first row I got no duplicate value and in the second value, columns in a and b which have the same row value get the maximum value in new matrix. i.e....

XQuery: find max value and return relevant information

max,xquery
I have a XML file containing elements with the following structure: <listing> <auction_info> <num_bids>29</num_bids> </auction_info> <item_info> <result>item A</result> </item_info> </listing> <listing> <auction_info> <num_bids>12</num_bids> </auction_info> <item_info> <result>item B</result> </item_info> </listing> I need a query to calculate the max of num_bids and return the result.In my example,the num_bids 29 is the max...

Finding the 3 largest numbers in an array/list of n numbers without the sorting

java,arrays,max
When I am doing my assignments I get really confused when I have to find the largest 3 numbers in a list of numbers(data structure not specified). I am totally struck with what I have to do. Any help?

Getting values for a varying date range in Postgresql

sql,postgresql,max,date-range
I am trying to get a maximum value from one table using the date range from another table. I am using SQL on a postgresql database. The goal is to get the maximum value for the date range added to the table that has the start and end date (by...

exception is not coming with sql max function

oracle,plsql,exception-handling,oracle11g,max
I wrote the below query expecting NO_DATA_FOUND exception to be thrown when no rows found. BEGIN SELECT MAX(A_id) + 1 INTO id_variable from table_A; EXCEPTION WHEN NO_DATA_FOUND THEN SELECT MAX(A_id) + 1 INTO id_variable from table_A_archive; END; there is no data in table_A but no exception was thrown and eventually...

the use of combining max, xrange and lambda function in python

python,lambda,max,xrange,matrix-decomposition
I have found a code that pivotize a square matrix for LU decomposition, but I can't understand some of them. def pivotize(m): """Creates the pivoting matrix for m.""" n = len(m) ID = [[float(i == j) for i in xrange(n)] for j in xrange(n)] for j in xrange(n): row =...

Linear Hashing: Fast Method for finding 'min' and 'max'

c++11,max,min
i implemented a min() and max() function for my Linear Hashtable, but i have little performance issue, because i implemented it straight forward. I just assume that the first element that has been found is the min/mix and then i compare the rest of the elements against it. Is there...

Excel with AND, IF, MAX

excel,if-statement,excel-formula,max,excel-2010
I can't quit figure out what I am doing wrong here, I know how to do the formula in multiple steps but can not figure out how to do it in one step all together. So what I am trying to do here is in column A there is numbers...

Conditionally assign unique values

excel,if-statement,excel-formula,max,worksheet-function
I have data, for example: John Doe MD 1 Ben Doe PA Cal Doe MD 1 Drum Doe PA Egg Doe NP Fun Doe MD 1 So everywhere there's an MD I have an IF condition assigning the number 1. But I want to isolate and pull all the names...

How to get a specific max value when there are ties in Ruby

ruby,max
I just started learning Ruby a few weeks ago so I apologize for being a complete noob. I am writing a simple program that will find the largest phone number input based on the sum of its digits. Here is what I have so far: print 'Enter phone numbers' phone_numbers...

How to get the last record from Ms Access table

sql,ms-access,join,max
I have 2 tables named Reefers and Alerts. I want to join these two tables. Now, how to get a result that shows the last record of each ReeferNo from Alerts table where the AlertType is equal to "Temperatures"? TABLE 1: Reefers ReeferNo Transporter E-110 Express1 E-111 Express1 E-112 Express1...

Max of Max on MYSQL

mysql,max,directed-acyclic-graphs
I'm making an Acyclic Graph database. TABLE Material (id_item,id_collection,...) PRIMARY KEY(id_item,id_collection) (item can be collection itself, item can be collection of collection) My constraint is id_collection > id_item (to prevent some cycle - 1st step) So before inserting i need to know "Max(Max(id_item), Max(id_collection))" I can get the 2 values...

SQL Server MAX and GROUP BY not playing nicely together

sql-server,tsql,group-by,max,aggregate-functions
I have a T-SQL query of the form: SELECT f.fizz_name, b.buzz_version, fu.foo_name FROM fizz f INNER JOIN buzz b ON f.fizz_id = b.fizz_id INNER JOIN foo fu ON b.buzz_id = fu.buzz_id WHERE f.bar LIKE 'YES' When I run this query I get the following results: fizz_name buzz_version foo_name ==================================== Gamma...

How to set maximum & minimum limits to date picker?

android,max,min,android-datepicker
I am using date picker in my application couples of time. I want my date picker to show dates following some restrictions. I am using the below code:- @Override protected Dialog onCreateDialog(int id) { switch(id) { case DATE_PICKER_DIALOG: datePickerDialogDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker datePicker, int selectedYear, int...

Finding the maximum integer value contained in a matrix using Java

java,matrix,integer,max
I try to code some of this: /* * @param ints * @return the max value in the array of chars */ public static int maxMatrix(int [][] ints) { int max = ints[0][0]; for(int i = 0; i < ints.length; i++) { for(int j = 0; j < ints.length){ max...

Converting SQL to LINQ using MAX

c#,sql,linq,max
I have two tables 1) T_EJV_CREDIT_DS_INDEX 2) T_EJV_CREDIT_DS_INDEX_CONTRACT I would like a SQL query like below as a LINQ expression SELECT MAX(INDEX_FAMILY_VERSION) FROM T_EJV_CREDIT_DS_INDEX cdi INNER JOIN T_EJV_CREDIT_DS_INDEX_CONTRACT cdic ON cdic.INDEX_ID = cdi.INDEX_ID WHERE cdi.INDEX_SHORT_NAME LIKE '%@VARIABLE1%' AND cdic.TENOR = @VARIABLE2 This is what I have attempted so far var...

How to get rows of max(count(*)) with inner select

mysql,count,max
I have a query that gets the max count of an inner select grouped by three fields. Now I don't only want to have the number, but the whole rows. I just can't figure it out. Here is the query that returns the number: SELECT MAX (count) FROM (SELECT COUNT...

how to get more than one max records in MySQL

mysql,max
This is the answers that I want to get.But if I used MAX() function in MySQL, it just return one record.How to handle it? A_plus ID 2 12345 2 45678 As decribed above,The SQL I used as fellow,but it just return one record. SELECT MAX(A_plus_Num) AS A_plus, ID FROM (SELECT...

Select max value from different column in a row in oracle database

sql,oracle,max
My table in oracle database is like this: Rollno | mark1 | Mark2 | mark3 --------+-----------+-----------+--------+ 101 | 10 | 20 | 30 102 | 22 | 44 | 08 103 | 55 | 11 | 14 --------+-----------+-----------+--------+ And I want output like Rollno | MAX(Mark1,mark2,mark3) --------+-------------------------+ 101 | 30...

Finding the highest price from three different tables

sql,max
I have to find the highest price from three different tables but I do not know how to get the max of P now. PC(model,speed,ram,hd,price) Laptop(model,speed,ram,hd,screen,price) Printer(model,color,type,price) SELECT model FROM ((SELECT MAX(price) FROM PC) UNION (SELECT MAX(price) FROM Laptop) UNION (SELECT MAX(price) FROM Printer)) AS P WHERE MAX(P); Could i...

SQL Get Most Recent Date

sql,sql-server,max
I am hoping someone can help me. I'm not that good with SQL. I've looked at countless other posts and just can't figure it out. I have the following data and need to get the most recent date. That would be 09/01/1993. 524 | David | NULL | 1991 |...

A function to calculate cumulative maximum for a double matrix in MATLAB

matlab,function,matrix,max
Is there any function that can calculate cumulative maximum for a double matrix? I have a 1*3000 matrix and I need to calculate the cumulative maximum. For example if the matrix is: A = [8 3 6 7 9 10 6 2 2 3] The cumulative maximum array will be:...

Postgres max on few columns

sql,postgresql,max,aggregate-functions
I have table, which looks like this id | item | price1 | price2 I want do get the list of items and for every item I want also to select max price among price1 and price2. Is it possible to do that in one query? Something like SELECT item,...

mysql: getting getting tuple of an alias which has maximum column value

mysql,sql,max,alias
What I want to do is this: select AlbumId from ( select Album.AlbumId, Sum(Track.UnitPrice) as Total from Album inner join Track on Album.AlbumId = Track.AlbumId group by Album.AlbumId ) tpt where Total = (select max(Total) from tpt); but am getting: Table 'db.tpt' doesn't exist -which probably makes sense. However, I...

MySQL max() - not returning max() value

mysql,sql,database,max
I have a query which I want to return the highest id value in idevent that is within a given range of sensor ID's (sensorID) however the query is not returning the highest value. The results when I run the query minus the max() statment: mysql> SELECT * FROM events...

awk script to find local minimum and local maximum from 2 clomun data

awk,max,min,derivative
I want to know simple implementation of finding local extreme from a datafile. Specifically saying, My input data is: x y 163.858 14.0919 166.269 14.2113 168.688 14.2855 # local max. 171.109 14.2766 173.524 14.1439 178.353 13.7528 180.768 13.6166 183.189 13.5753 # local min. 185.61 13.6128 188.03 13.6525 190.454 13.776 195.281...

Multiple same values in Column A, need to find the greater date in column B

excel,if-statement,max,excel-2010,array-formulas
I'm stumped on a particular problem with some data that's imported to me. I have zero control over how the data is coming in. (Just to clarify that point). I have two columns and 107,000 rows. Column A has an ID#, Column B has the corresponding Date. The issue I...

find column which have biggest number of approved transactions sql server

sql,sql-server,max
I need to find the Filiyal which have biggest number of approved transactions. I've try like this: select max(Filiyal) from Transactions where Status = 'Approved' But it gives me wrong result. Where I'm wrong? Here is my table: Filiyal | Status ------------------------- Bank1 | Approved Bank2 | Not Approved Bank1...

Finding maximal sum of happiness

algorithm,sum,max,hungarian-algorithm
I have a problem to solve, and do not see any optimal solution :/ The problem is: I have n workers and k jobs. Each job is to be done by specified number of workers, and each worker has his level of happines for each job. I have to to...

d3.max didn't get the correct value [duplicate]

javascript,d3.js,max
This question already has an answer here: D3.js scale returning wrong values from dataset 1 answer I am using d3.js to render some data and the data set is a csv file called bar-data.csv like this: date,value,duration www.sina.com,53,100 www.baidu.com,165,2000 www.qq.com,269,690 www.youku.com,421,224 www.facebook.com,405,345 www.apple.com,376,777 www.cnn.com,359,298 www.cctv.com,433,333 www.google.com,455,500 www.boston.com,670,274 However when...

How to write Max(L)<1 without using MAX func in MATLAB

matlab,optimization,max
I have an optimization problem which is solved with fmincon. In this problem I have a constraint that says every element of the vector L must be less than or equal to 1. So basicaly I can add this constraint like this C=max(L)-1 ; % C(X)<0 But now I want...

Javascript - biggest number from array using loop [closed]

javascript,arrays,for-loop,max
Can somebody please explain how this code gets which number from array is the biggest? var num = []; for( var i = 0; i < 10; i++ ) { num[i] = parseInt( prompt("Unesite broj " + (i+1) + "." ) ); } var biggest = 0; for(i=0; i <...

incomplete output ms access 2007 [closed]

sql,ms-access-2007,max,average
SELECT temp.hhid, temp.country, temp.max_prod, temp.max_area, gen.price_seed, gen.qty_seed, gen.price FROM (SELECT hhid, country, MAX(area) AS max_area, max(total_prod) AS max_prod FROM gen GROUP BY hhid, country) AS temp, gen WHERE (((temp.hhid)=gen.hhid) And ((temp.country)=gen.country) And ((temp.max_prod)=gen.total_prod) And ((temp.max_area)=gen.area)) ORDER BY temp.hhid; Why do some of the results were not seen? I have atleast...

How to find a max value

python,max
I am new to python, and am trying to learn it with newmans computational physics. I was trying to make a program to solve one of the exercises. It is to calculate the highest binding energy using an approximate formula . I made this program, to find the binding energy:...

get distinct row and use coalesce if id not exist in other table

mysql,join,max,distinct,coalesce
I have two tables: Job_Order -id -creation_date -assigned_to -job_ordertype -client Job_Order_Stage -id -stage -date -job_order(foreign key to job_order) I want to get all rows in the job_order and set stage to 0 if id not exist in the Job_Order_Stage. And I also want to get only the row with max(stage)...

Max() function does not return largest value in Python 3.4

python,python-3.x,max
Why does the max() function in Python 3.4 is giving me values smaller than expected in a list of values? Example 1, where expected value is 'marco': >>> max('zara', 'marco') 'zara' Example 2, where expected value is 'cherries': >>> max('apples', 'oranges', 'cherries', 'banana') 'oranges' ...

Increase the maximum size of char array

c,arrays,char,size,max
I have written some code in C by taking the maximum size of char array as 100. It worked well. But when I increase the maximum size of char array to 10000 it gives me segmentation fault(as it has exceeded its limit). Can someone tell me how can I increase...

how to select max value and return many entries

mysql,sql,max
Suppose I have such a table : theme module changed 0 1 1426070691 1 1 1426070300 0 1 1324014321 1 2 1241245585 1 1 1015421251 I need a SQL query that returns for the same theme and module the max value of changed: theme module changed 0 1 1426070691 1...

Access rawValue of enum in array in Swift

arrays,swift,enums,max,member
I'm trying to use maxElement to work with enums in an array, accessed by .rawValue as shown in the example below: var planets: [Planets] = [.Mars, .Earth, .Jupiter] maxElement(planets.rawValue) I could just use other methods to get the max rawValue but it would be so nice and easy if it...

Mysql select max variable value

mysql,variables,max
I have a temporary table and the following query: Select *, @rnkma:=IF(age>17 and age<22,@rnkma+1,@rnkma), @rnkmb:=IF(age>21 and age<25,@rnkmb+1,@rnkmb), @rnkmc:=IF(age>24 and age<30,@rnkmc+1,@rnkmc), @rnkmd:=IF(age>29 and age<35,@rnkmd+1,@rnkmd), @rnkme:=IF(age>34 ,@rnkme+1,@rnkme) from tmp_user where gender='M'; Select @rnkma, @rnkmb, @rnkmc, @rnkmd ; The result is: @rnkma @rnkmb @rnkmc @rnkmd 5 8 3 4 I want to get...

Finding the maximum of a curve scipy

python,matplotlib,scipy,max
I have fitted curve to a set of data points. I would like to know how to find the maximum point of my curve and then I would like to annotate that point (I don't want to use by largest y value from my data to do this). I cannot...

T-SQL Insert when not in table and when max timestamp Issue

sql-server,tsql,sql-server-2012,max,sql-insert
I am trying to insert rows from one table to another that are not in the one I am moving them to. I also want to only move the ones that have the highest datestamp. (I want to only insert rows that are not in tb1 and have the max...

SQL: age of oldest items

sql,oracle,select,max
I have following Oracle database. A certain ID can have an accepted status, but can continue in a failed status, and return back in an accepted status. This can happen X time, so it can be called a loop ID STATUS TIME INSERT ------------------------------ 1 Accepted 01:00:00 1 Failed 02:00:00...

Python dictionary of lists maximum based on on 3rd element from list

python,list,dictionary,lambda,max
I have a dictionary of lists h={'1':['a','3','56'],'2':['a','2','125']} I want to get the key and value for the maximum based on third element of h[k] i.e (2,125) I tried to understand lambda function and wrote this: max(h, key=lambda h : int(h[k][2]) for k in h.keys()) But it gives me a SyntaxError...

Adding max(count) and min(count) to query

sql,oracle11g,max,min
I am trying to add max and min to the query below: SELECT category, COUNT(distinct VIN) COUNT FROM stock group by category order by category ASC The desired results are to show the category with the most items in the count and to show the category with the least items...

Max MSP. How I initialize a BPM counter/ tempo recognizer with a massage if bmp changes?

max,counter,tempo,max-msp-jitter
i need a bpm counter witch send a message if a tempo of incoming Audiosignal changes. Have anyone an idee?

join 2 tables and get some columns from 1st table and max timestamp value from second table

sql,join,db2,max,left-join
I have a employee table empid empname status 1 raj active 2 ravi active 3 ramu active 4 dan active 5 sam inactive I have another table called facilities empid timestamp 1 2014-12-28 1 2015-05-05 1 2015-06-05 2 2015-05-03 2 2015-06-04 3 2015-02-01 I want my result like empid empname...

Return highest number value in column cell plus a related row cell data

excel,excel-formula,max,concatenation,worksheet-function
|A B C D --------|--------------------------------- 1 |YEAR NAME UNITS SOLD 2 |2011 Jon 99 55 3 |2012 Jon 70 22 4 |2013 Jon 65 34 5 |2014 Jon 78 44 I would like to know how to find the year Jon sold the most (in this case the 55...

Finding max and identify name's cell for another column

r,max
Hopefully someone can solve me the following problem. Here I have a data about different birds and their maximum lengths: a<-c("bird1","bird2","bird1","bird3","bird2","bird2") b<-c(32,45,35,25,51,47) c<-data.frame(animal=a,max=b) animal max 1 bird1 32 2 bird2 45 3 bird1 35 4 bird3 25 5 bird2 51 6 bird2 47 My purpose is to identify the name...

Most recent date and price from multiple tables in SQL Server

sql-server,max
I have 5 tables: contracts, contracts_data, contracts_anexes, anexes, anexes_data Table contracts columns : id_contract | date_sign ------------+----------- 1 | 2013-01-03 2 | 2013-06-05 3 | 2014-10-12 Table contracts_data columns : id_contract | price ------------+------ 1 | 100 2 | 200 3 | 300 Table uontracts_anexes columns : id_contract | id_anex...

Learning to use methods, keep getting error: “cannot convert from void to int”

java,methods,max,min
I'm trying to make a script that prints out the biggest and smallest number using methods, however I have no clue why my methods don't work... I placed a comment next to where I keep getting the error. I don't really need help with getting the script to work however...

Javascript (node.js) capped number of child processes

javascript,node.js,max,child-process
hopefully I can describe what I'm looking for clearly enough. Working with Node and Python. I'm trying to run a number of child processes (.py scripts, using child_process.exec()) in parallel, but no more than a specified number at a time (say, 2). I receive an unknown number of requests in...

Select MAX value from SQL table to apply in another table

php,mysql,max
My site is a Prestashop (1.5.6.2). Some of my product can have a lower price according to the number of product ordered. And I'd like to mention somewhere the minimum price of the product (so I need the maximum amount of reduction to make this happen). Table 1 (my price...

How to get get max value in java? [closed]

java,for-loop,max
I am writing a program that finds the taxes based on a person's income. So far the problem I am running into is some numbers that come out don't round up two decimal places and keep on going and I don't know how to get the max out of all...