max

Select latest row from multiple tables

南笙酒味 提交于 2020-01-06 07:26:07
问题 I have this query with multiple tables and I got the following result. Then I want to group by t.id. I know I can simply use group by t.id but how can I select the latest row of t.id which is url tw5.jpg and created_time 10000004 SELECT p.url,t.name,t.num_photo,t.id FROM photos AS p LEFT JOIN tag_maps AS tm ON p.id = tm.photo_id LEFT JOIN tags AS t ON t.id = tm.tag_id url created_time name num_photo id assets/img/tags/tw1.jpg 1000001 my house 1 1 assets/img/tags/tw2.jpg 1000002 dog 1 2 assets

How do keys work in min and max?

吃可爱长大的小学妹 提交于 2020-01-05 23:00:18
问题 I run through the following sequence of statements: >>> a = range(10) >>> min(a, key=lambda x: x < 5.3) 6 >>> max(a, key=lambda x: x < 5.3) 0 The min and max give the exact opposite of what I was expecting. The python documentation on min and max is pretty sketchy. Can anyone explain to me how the "key" works? 回答1: Explanation of the key argument Key works like this: a_list = ['apple', 'banana', 'canary', 'doll', 'elephant'] min(a_list, key=len) returns 'doll' , and max(a_list, key=len)

Determining Maximum and Mean of an User-Provided Array in Java

不问归期 提交于 2020-01-05 19:24:28
问题 I am new to coding so be easy on me. I am trying to determine the maximum and mean of an user-provided array using two separate classes (i.e. xyz and a separate xyztester class). I've have my coding but the maximum output is 0.0 and the mean output is one less than the length of the array. Here is my coding - "xyz" class public static double maximum(double[] array){ double max = array[0]; for (int j = 1; j < array.length; j++){ if(array[j] > max){ max = array[j]; } } return max; } public

Determining Maximum and Mean of an User-Provided Array in Java

点点圈 提交于 2020-01-05 19:24:10
问题 I am new to coding so be easy on me. I am trying to determine the maximum and mean of an user-provided array using two separate classes (i.e. xyz and a separate xyztester class). I've have my coding but the maximum output is 0.0 and the mean output is one less than the length of the array. Here is my coding - "xyz" class public static double maximum(double[] array){ double max = array[0]; for (int j = 1; j < array.length; j++){ if(array[j] > max){ max = array[j]; } } return max; } public

Find the highest and lowest value locations within an interval on a column?

血红的双手。 提交于 2020-01-05 07:53:06
问题 Given this pandas dataframe with two columns, 'Values' and 'Intervals'. How do I get a third column 'MinMax' indicating whether the value is a maximum or a minimum within that interval? The challenge for me is that the interval length and the distance between intervals are not fixed, therefore I post the question. import pandas as pd import numpy as np data = pd.DataFrame([ [1879.289,np.nan],[1879.281,np.nan],[1879.292,1],[1879.295,1],[1879.481,1],[1879.294,1],[1879.268,1], [1879.293,1],[1879

How to use max() on a collection?

眉间皱痕 提交于 2020-01-05 05:33:08
问题 I have a dataset that looks something like this: CREATE (n {name:'main', val:3}) -[:r]-> ({name:'sub1', val:2}), (n)-[:r]->({name:'sub2', val:1}) Now, I need to find the maximum value for 'val' for all nodes that are connected to the node named 'main' (including 'main' too). So, in this case the answer is 3. Since the node named 'main' may not have any subnodes, I used OPTIONAL MATCH to find the subnodes, then combine all the vals found into a list and call max() on it, like so: MATCH (n

Conditionally calculating the difference between max(raster) and each raster layer of raster stack

送分小仙女□ 提交于 2020-01-05 04:35:14
问题 I have a list of raster stacks named r.lst . I need to calculate the difference between max(r.lst[[i]]) (stacked rasters) and every raster layer of that raster stack. However, I want to do this conditionally for each pixel by considering which.max(r.lst[[i]]) . So that each cell in deducted from its previous max not the next. Please see below example: # example data------------------------------------------- set.seed(123) #our list of rasters r.lst <- as.list(1:3) # setting up list pf raster

MySQL Select Where max date and max time

淺唱寂寞╮ 提交于 2020-01-05 04:09:16
问题 I have this kind of table: CREATE TABLE Buckets ( id INT UNSIGNED AUTO_INCREMENT, checkDate DATE NOT NULL, checkTime TIME NOT NULL, accountId CHAR(13), costCenter VARCHAR(30), percentage DECIMAL(5,2), UNIQUE INDEX (checkDate, checkTime, accountId, costCenter), PRIMARY KEY (id) )ENGINE=InnoDB; There I have currently this kind of data: 1 2014-03-24 08:11:27 387909559196 72350 86.92 2 2014-03-24 08:11:27 387909559196 analytics 12.71 3 2014-03-24 08:11:27 387909559196 json-files 0.36 4 2014-03-24

Auto-delete Max/Min from Array on creation

我的未来我决定 提交于 2020-01-04 02:18:10
问题 Updated Code that creates array, but ISNT outputting the min/max values. Why isnt this working and how do I get it to automatically remove the min/max value and then reoutput the array? <?php $url = 'https://www.googleapis.com/shopping/search/v1/public/products?key=thekey&country=US&q=nintendo+wii'; $data = curl_init($url); curl_setopt($data, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($data, CURLOPT_HEADER, 0); $product_result = curl_exec($data); curl_close($data); $arr = json_decode($product

max function c tree height

女生的网名这么多〃 提交于 2020-01-04 02:18:06
问题 is there a max function in c so i can do something like this to calculate tree height :or perhaps there is a better way to calculate tree height. int height(struct node *tree) { if (tree == NULL) return 0; return 1 + max(height (tree->left), height (tree->right)); } if so what includes do i need? currently i get this error : dict-tree.o: In function 'height': /home/ex10/dict-tree.c:36: undefined reference to `max' 回答1: Probably because max is an undefined function, try implementing max first