max

SQL: How would you split a 100,000 records from a Oracle table into 5 chunks?

自闭症网瘾萝莉.ら 提交于 2020-01-04 02:04:16
问题 I'm trying to figure out away to split the first 100,000 records from a table that has 1 million+ records into 5 (five) 20,000 records chunks to go into a file? Maybe some SQL that will get the min and max rowid or primary id for each 5 chunks of 20,000 records, so I can put the min and max value into a variable and pass it into the SQL and use a BETWEEN in the where clause to the SQL. Can this be done? I'm on an Oracle 11g database. Thanks in advance. 回答1: If you just want to assign values 1

Numpy: Dot product with max instead of sum

北城余情 提交于 2020-01-03 20:23:10
问题 Is there a way in numpy to do the following (or is there a general mathematical term for this): Assume normal dot product: M3[i,k] = sum_j(M1[i,j] * M2[j,k]) Now I would like to replace the sum by sum other operation, say the maximum: M3[i,k] = max_j(M1[i,j] * M2[j,k]) As you can see it is completely parallel to the above, just we take max over all j and not the sum. Other options could be min , prod , and whatever other operation that turns a sequence/set into a value. 回答1: Normal dot

Fast search for the coordinates of the maximum value in a gaussian kernel

99封情书 提交于 2020-01-03 17:10:49
问题 I have a simple code that generates a 2D gaussian kernel using scipy.stats.gaussian_kde function. Here's the MWE : def random_data(N): # Generate some random data. return np.random.uniform(0., 10., N) # Data lists. x_data = random_data(10000) y_data = random_data(10000) # Obtain the KDE for this region. kernel = stats.gaussian_kde(np.vstack([x_data, y_data]), bw_method=0.05) and here's the result: What I need is a way to obtain the x,y coordinates of the maximum value in this KDE. For what I

Find the Max and Min element out of all the nested arrays in javascript

社会主义新天地 提交于 2020-01-03 14:24:20
问题 I have a array like so: var arr = [[12,45,75], [54,45,2],[23,54,75,2]]; I want to find out the largest element and the smallest element out of all the elements in the nested array: The min should be: 2 and Max should be 75 I tried the functions below but they do not work: function Max(arrs) { if (!arrs || !arrs.length) return undefined; let max = Math.max.apply(window, arrs[0]), m, f = function(v){ return !isNaN(v); }; for (let i = 1, l = arrs.length; i<l; i++) { if ((m = Math.max.apply

Excel Find the largest partial value in an indexed list

[亡魂溺海] 提交于 2020-01-03 02:54:13
问题 I am working with excel and trying to find if a portion of one cell matches anything from a list. I am attempting to extract that part of the cell as my result. The formula I am working with is: {=INDEX($A$1:$A$10,MATCH(1,COUNTIF(B1,"* "&$A$1:$A$10&"*"),0))} note: had to space out the asterisk to avoid italics A1 to A10 is the list i am referencing and anything in column B is what I am searching partail parts for in the list The problem is the formula return the most common value found in the

MongoDB max in group results

好久不见. 提交于 2020-01-03 01:40:28
问题 I grouped results by mvid and the counted number of occurrences in each group. db.some_details.aggregate([ {$group: {_id: "$mvid", count: {$sum: 1}}} ]) Now, I would like to select group with max count. Here is my naive guess: db.some_details.aggregate([ {$group: {_id: "$mvid", count: {$sum: 1}}}, {$max: "count"} ]) It, obviously, generates an error. I need to use max with group, but I don't have anything to group on. 回答1: What also would work is sorting the result and then using only the

How to group and select document corresponding to max within each group in MongoDB?

戏子无情 提交于 2020-01-02 19:31:44
问题 Here is my mongo collection 'sales': {"title":"Foo", "hash": 17, "num_sold": 49, "place": "ABC"} {"title":"Bar", "hash": 18, "num_sold": 55, "place": "CDF"} {"title":"Baz", "hash": 17, "num_sold": 55, "place": "JKN"} {"title":"Spam", "hash": 17, "num_sold": 20, "place": "ZSD"} {"title":"Eggs", "hash": 18, "num_sold": 20, "place": "ZDF"} I would like to group by hash and return document with the greatest "num_sold". So as output I would like to see: {"title":"Baz", "hash": 17, "num_sold": 55,

MySQL query for max() of all columns

倖福魔咒の 提交于 2020-01-02 10:16:09
问题 What is the correct way of retrieving maximum values of all columns in a table with a single query? Thanks. Clarification: the same query should work on any table, i.e. the column names are not to be hard-coded into it. 回答1: You're going to have to do it in two steps - one to retrieve the structure of the table, followed by a second step to retrieve the max values for each In php: $table = "aTableName"; $columnsResult = mysql_query("SHOW COLUMNS FROM $table"); $maxValsSelect = ""; while (

Select only largest values in a SQL relation?

橙三吉。 提交于 2020-01-02 09:13:47
问题 I have the following two relations: Game(id, name, year) Devs(pid, gid, role) Where Game.id is a primary key, and where Devs.gid is a foreign key to Game.id. I want to write a SQL query that finds the game with the largest amount of people who worked on that game. I wrote the following query: SELECT Game.name, count(DISTINCT Devs.pid) FROM Game, Devs WHERE Devs.gid=Game.id GROUP BY Devs.gid, Game.name ORDER BY count(Devs.pid) DESC; This query sort of accomplishes my goal, in the sense that it

Select only largest values in a SQL relation?

久未见 提交于 2020-01-02 09:13:35
问题 I have the following two relations: Game(id, name, year) Devs(pid, gid, role) Where Game.id is a primary key, and where Devs.gid is a foreign key to Game.id. I want to write a SQL query that finds the game with the largest amount of people who worked on that game. I wrote the following query: SELECT Game.name, count(DISTINCT Devs.pid) FROM Game, Devs WHERE Devs.gid=Game.id GROUP BY Devs.gid, Game.name ORDER BY count(Devs.pid) DESC; This query sort of accomplishes my goal, in the sense that it