min

How do I get the MIN() of two fields in Postgres?

大城市里の小女人 提交于 2019-11-30 07:47:24
Let's say I have a table like this: name | score_a | score_b -----+---------+-------- Joe | 100 | 24 Sam | 96 | 438 Bob | 76 | 101 ... | ... | ... I'd like to select the minimum of score_a and score_b. In other words, something like: SELECT name, MIN(score_a, score_b) FROM table The results, of course, would be: name | min -----+----- Joe | 24 Sam | 96 Bob | 76 ... | ... However, when I try this in Postgres, I get, "No function matches the given name and argument types. You may need to add explicit type casts." MAX() and MIN() appear to work across rows rather than columns. Is it possible to

How would you define a simple “min” method in obj-c

被刻印的时光 ゝ 提交于 2019-11-30 07:22:28
问题 I want to define a min and max methods in a Utils class. @interface Utils int min(int a, int b); int max(int a, int b); @end But I don't want to have named parameters. It would be a too heavy notation. I wanted to use the C-style definition. But then [Utils min(a, b)] as a call doesn't work. What is my problem? Thanks in advance for any help 回答1: Since you aren't using the OS X Implementation of objective-c, you may not have access to the predefined MIN and MAX macros. You can define these

How to Minify HTML code?

戏子无情 提交于 2019-11-30 07:13:48
My idea is to somehow minify HTML code in server-side, so client receive less bytes. What do I mean with "minify"? Not zipping. More like, for example, jQuery creators do with .min .js versions. In other words, I need to remove unnecessary white-spaces and new-lines, but I can't remove so much that presentation of HTML changes (for example remove white-space between actual words in paragraph). Is there any tools that can do it? I know there is HtmlPurifier . Is it able to do it? Any other options? P.S. Please don't offer regex'ies. I know that only Chuck Norris can parse HTML with them. =] You

MinGW error: 'min' is not a member of 'std'

旧城冷巷雨未停 提交于 2019-11-30 02:51:15
问题 I'm trying to convert some VC++ 6 code to a console app using only the standard libraries but am getting the following error from MinGW (whatever version is supplied with the Code::Blocks 10.05 IDE): error: 'min' is not a member of 'std' This is related to the following line of code: L.Precision=std::min(1.e-4,0.001*res); L.Precision is a double , and res is a double . Previously this line was: L.Precision=min(1.e-4,0.001*res); But this gives the error: error: 'min' was not declared in this

Counter-intuitive behavior of min_member/2

巧了我就是萌 提交于 2019-11-30 02:51:11
问题 min_member(-Min, +List) True when Min is the smallest member in the standard order of terms. Fails if List is empty. ?- min_member(3, [1,2,X]). X = 3. The explanation is of course that variables come before all other terms in the standard order of terms, and unification is used. However, the reported solution feels somehow wrong. How can it be justified? How should I interpret this solution? EDIT: One way to prevent min_member/2 from succeeding with this solution is to change the standard

What's “<?=” operator in C++? [duplicate]

强颜欢笑 提交于 2019-11-30 01:08:46
问题 This question already has answers here : C extension: <? and >? operators (2 answers) Closed 5 years ago . I came across the following code here, which is from the C++ implementation of Dijkstra algorithm using an adjacency matrix. //read in edges keeping only the minimum for(int i=0; i<E; i++) { int v1,v2,tmp; fin >> v1; fin >> v2; fin >> tmp; adjmat[v1][v2]<?=tmp; // <?= sets left to min(left,right) adjmat[v2][v1]<?=tmp; } Pay attention to the last two lines, which apply operator <?= . As

Tuple pairs, finding minimum using python

不羁的心 提交于 2019-11-29 20:34:46
I want to find the minimum of a list of tuples sorting by a given column. I have some data arranged as a list of 2-tuples for example. data = [ (1, 7.57), (2, 2.1), (3, 1.2), (4, 2.1), (5, 0.01), (6, 0.5), (7, 0.2), (8, 0.6)] How may I find the min of the dataset by the comparison of the second number in the tuples only? i.e. data[0][1] = 7.57 data[1][1] = 2.1 min( data ) = (5, 0.01) min( data ) returns (1, 7.57) , which I accept is correct for the minimum of index 0, but I want minimum of index 1. In [2]: min(data, key = lambda t: t[1]) Out[2]: (5, 0.01) or: In [3]: import operator In [4]:

MySQL: Select N rows, but with only unique values in one column

自闭症网瘾萝莉.ら 提交于 2019-11-29 20:17:30
Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957 2 Mac Taylor New York 1955 3 Sarah Connor Los Angeles 1959 4 Jean-Luc Picard La Barre 2305 5 Ellen Ripley Nostromo 2092 6 James T. Kirk Riverside 2233 7 Henry Jones Chicago 1899 I need to find the 3 oldest persons, but only one of every city. If it would just be the three oldest, it would be... Henry Jones / Chicago Mac Taylor / New York Egon Spengler / New York However since both Egon Spengler and Mac Taylor are located in New York, Egon Spengler would drop out and the next one (Sarah Connor / Los Angeles) would come in

Using std::max_element on a vector<double>

孤街醉人 提交于 2019-11-29 19:34:54
I'm trying to use std::min_element and std::max_element to return the min and max elements in a vector of doubles. My compiler doesn't like how I'm currently trying to use them, and I don't understand the error message. I could of course write my own procedure to find the min/max, but I'd like to understand how to use the functions. #include <vector> #include <algorithm> using namespace std; int main(int argc, char** argv) { double cLower, cUpper; vector<double> C; // code to insert values in C not shown here cLower = min_element(C.begin(), C.end()); cUpper = max_element(C.begin(), C.end());

PowerPivot DAX - Dynamic Ranking Per Group (Min Per Group)

戏子无情 提交于 2019-11-29 14:06:55
I am searching for a method to utilize within Microsoft PowerPivot 2010 that will allow me to perform dynamic ranking that will automatically update the associated rank value based on filters and slicer values that are applied. Thusfar, all examples I have seen utilize the Calculate() DAX function that overrides existing filters within the PowerPivot table via the All() function which causes predefined filters that users may apply to be disregarded. To illustrate my requirements, please reference the example below: (Source Data within PowerPivot Window:) ---------------------------------------