I'm trying to get the greatest value of just 1 row (mult columns). All of the tutorials I've watched are for multiple rows.  How can have just the greatest value (4943) returned? Thanks!
10446
How do you return 1 value per row of the max of several columns:  TableName  [Number, Date1, Date2, Date3, Cost]   I need to return something like this:  [Number, Most_Recent_Date, Cost]   Query?
103206
How many &quot;$1$&quot; can be selected at most, provided that only one from each row and column of the attached matrix $A$ is selected?(That is, when one &quot;$1$&quot; is selected, no other element can be selected than the row and column where that &quot;$1$&quot; is located.)  Answer: I think $6$ can be chosen.  How can I give this answer in connection with graph theory? I think it has to do with the Latin Square(or Rectangle). But I can't connect and explain. Please help me. I thought a lot, but I could not establish the relationship completely. Thanks...
85118
If $x^4+ax^3+3x^2+bx+1 \ge 0$ for all real $x$ where $a,b \in R$. Find the maximum value of $(a^2+b^2)$.                                                                        I tried setting up inequalities in $a$ and $b$ but in the end had a hideous two variable expression whose maxima I had to calculate using Partial Derivatives. There must be a better way of doing it. Thanks!
43671
I have written below inner join query to get the data from my database tables. But  output of this data is coming up with almost 140+ lines. Output is below. I need data in only one row with the most recent value by "TimeSampled"    select DisplayName, ObjectName, CounterName, InstanceName, SampleValue, max(TimeSampled) as TimeSampled from PerformanceDataAllView pdv with (NOLOCK) inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId where ObjectName = 'Processor'  AND TimeSampled &gt;= DATEADD(MINUTE,-5,GETDATE()) AND DisplayName Like 'BLRW1ETST01.jcp.com' AND CounterName = '% Processor Time' GROUP BY DisplayName, ObjectName, CounterName, InstanceName, SampleValue ORDER BY  TimeSampled desc   How I can retrive results with only last Time Sampled row with respect to DisplayName. I have multiple servers (DisplayName) like this to retrieve the data.  Thanks, Ramu Chittiprolu
50351
I have multiple set of data to insert at once, say 4 rows. My table has three columns: Person, Id and Office.  INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office"); INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office"); INSERT INTO MyTable VALUES ("Billy", 125, "London Office"); INSERT INTO MyTable VALUES ("Miranda", 126, "Bristol Office");   Can I insert all 4 rows in a single SQL statement?
55154
I'm sure its a simple question and I suppose it was asked many times, but I just can't figure it out from other answers, sorry.  I use recent versions of PostgreSQL and MySQL. I have 2 tables:  CREATE TABLE authors (     id INT,     name VARCHAR )  CREATE TABLE posts (     id INT,     author_id INT,     text VARCHAR,     date DATE )   I need to select one most recent post for each author. Thanks!  UPDATE  Thanks, both links provide answers to my question with some exception. All the following queries give the same result (which one is the most efficient btw?) The issue is when there is more than one post from the same author with the same date. Then the returned result set contains all such posts. How should I modify these queries to return exactly one post per author?  SELECT p1.* FROM posts p1 LEFT JOIN posts p2 ON p1.author_id = p2.author_id AND p1.date &lt; p2.date WHERE p2.author_id IS NULL ORDER BY p1.author_id;  SELECT p1.*  FROM posts p1 INNER JOIN (   SELECT author_id, MAX(date) AS max_date   FROM posts   GROUP BY author_id) p2   ON p1.author_id = p2.author_id AND p1.date = p2.max_date ORDER BY p1.author_id;  SELECT * FROM posts p1 WHERE date = (SELECT MAX(p2.date)               FROM posts p2               WHERE p1.author_id = p2.author_id) ORDER BY author_id;  SELECT * FROM (     SELECT author_id, MAX(date) date     FROM posts GROUP BY author_id ) p1 INNER JOIN posts p2 USING (author_id, date) ORDER BY author_id;
12728
Maximum value of $\cos \alpha_{1}\cdot \cos \alpha_{2}\cdot \cos \alpha_{3}\cdot \cos \alpha_{4}....\cos \alpha_{n}.$ If it is given that   $\cot \alpha_{1}\cdot \cot \alpha_{2}\cdot \cot \alpha_{3}.......\cot \alpha_{n}  = 1$ and $\displaystyle 0 \leq \alpha_{1},\alpha_{2},\alpha_{3},.......,\alpha_{n}\leq \frac{\pi}{2}.$  $\bf{My\; Try::}$ Using $\bf{A.M\geq G.M}$ $$\displaystyle \frac{\sin^2 \alpha_{1}+\sin^2 \alpha_{2}+\sin^2 \alpha_{3}+........+\sin^2 \alpha_{n}}{n}\geq \sqrt[n]{\sin^2 \alpha_{1}\cdot \sin^2 \alpha_{2}...\sin^2 \alpha_{n}}$$ So we get $$\displaystyle \sin^2 \alpha_{1}+\sin^2 \alpha_{2}+\sin^2 \alpha_{3}+........+\sin^2 \alpha_{n}\geq n\cdot \sqrt[n]{\sin^2 \alpha_{1}\cdot \sin^2 \alpha_{2}...\sin^2 \alpha_{n}}.......(1)$$ Similarly $$\displaystyle \frac{\cos^2 \alpha_{1}+\cos^2 \alpha_{2}+\cos^2 \alpha_{3}+........+\cos^2 \alpha_{n}}{n}\geq \sqrt[n]{\cos^2 \alpha_{1}\cdot \cos^2 \alpha_{2}...\cos^2 \alpha_{n}}$$ So we get $$\displaystyle \cos^2 \alpha_{1}+\cos^2 \alpha_{2}+\cos^2 \alpha_{3}+........+\cos^2 \alpha_{n}\geq n\cdot \sqrt[n]{\cos^2 \alpha_{1}\cdot \cos^2 \alpha_{2}...\cos^2 \alpha_{n}}.......(2)$$ Now Adding $(1)$ and $(2)\;,$ We get $$n\geq 2n\cdot \sqrt[n]{\cos^2 \alpha_{1}\cdot \cos^2 \alpha_{2}...\cos^2 \alpha_{n}}$$ Because above it is given that $$\sin \alpha_{1}\cdot \sin\alpha_{2}\cdot\sin \alpha_{3}.........\sin\alpha_{n}=\cos\alpha_{1} \cdot\cos\alpha_{2}\cdot \sin\alpha_{3}......\cos\alpha_{n}$$ So we get $$\displaystyle \cos \alpha_{1}\cdot \cos \alpha_{2}\cdot \cos \alpha_{3}\cdot \cos \alpha_{4}....\cos \alpha_{n}\leq \frac{1}{2^{\frac{n}{2}}}$$ My question is that can we solve it using any other short method? If yes then please explain it here. Thanks.
111744
Say I have a table called User_FriendList, which has the following characteristics:  CREATE TABLE User_FriendList (     ID ...,     User_ID...,     FriendList_IDs...,     CONSTRAINT User_Friendlist_PK PRIMARY KEY (ID) );   And let us suppose that said table holds the following data:    +----+---------+---------------------------+  | ID | User_ID | Friendlist_IDs            |  +----+---------+---------------------------+  | 1  | 102     | 2:15:66:35:26:17:         |  +----+---------+---------------------------+  | 2  | 114     | 1:12:63:33:24:16:102      |  +----+---------+---------------------------+  | 3  | 117     | 6:24:52:61:23:90:97:118   |  +----+---------+---------------------------+   Note: The “:” (colon) is the delimiter when exploding in PHP into an array.  Questions  So:   Is this a convenient way to “store” the IDs of a FriendList? Or, instead, should I have individual rows with only one single FriendId value in each of them and, when I need to retrieve all the rows of a given list, simply perform a query like SELECT * FROM UserFriendList WHERE UserId = 1?
35680
I'm trying to apply a LARGE function to get the 5 largest values from a column ignoring duplicates. I did some searching around and found some proposed solutions but they don't seem to work for me. In my actual application the range is found by an array formula so I'm not sure if non array formulas will work here. My original function was {=LARGE(IF($A:$A=$A2,$B:$B),2)} dragged down the column. Replace 2 with 3 for the third largest, 4 for the fourth largest, etc. This worked except in the case of duplicates.  For example:  The data is in column 1 and the desired output is in column 2:  1    5  2    4 2    3 3    2  3    1 3 4 4 5   Things I have tried:   {=LARGE(IF(A:A &lt; LARGE(A:A,i-1),A:A),1)} for the i-th largest value.    -Inputting this gives 3 for both i = 3 and i = 4. =LARGE(A:A,COUNTIF(A:A,MAX(A:A))+1)   -This doesn't seem to be any different than just LARGE(A:A,2) {=MAX(IF(A:A &lt; LOOKUP(9.99999999999999E+307,A:A),A:A))}  -This does retrieve the value 4 but I'm not sure how to generalize it to the kth largest value.    VBA solutions are fine as well. I tried to code one myself but wasn't sure how to code in the array formula IF($A:$A=$A2,$B:$B).
12722
If $a,b,c,d$ are positive integers with    $$a+b+c+d=63,$$   what is the maximum value of $$ab+bc+cd?$$   I treated this as an optimization problem and tried to solve it but I did not make any progress.
110905
I have a table in Excel.  Can anyone help me find the column number of the cell where the min value of the row is?  Example: 200 is the min value in row1 and has the column number 1. Is there a function that returns the column number of the min value?           col1  col2  col3  col4  col5   row1 - 200 - 300 - 400 - 500 - 600  row2 - ... - ... - ... - ... - ...
7766
This is a very basic query I can't figure out....  Let's say I have a two column table like this:  userid  |  roleid --------|--------    1    |    1    1    |    2    1    |    3    2    |    1   I want to get all distinct userids that have roleids 1, 2 AND 3.  Using the above example, the only result I want returned is userid 1.  How do I do this?
75502
I have a tabular file in which the first column has IDs and the second one has numeric values. I need to generate a file that contains only the line with the largest score for each ID.  So, I want to take this:  ES.001      2.33 ES.001      1.39 ES.001    119.55 ES.001     14.55 ES.073      0.35 ES.073     17.95 ES.140      1.14 ES.140     53.88 ES.140     18.28 ES.178    150.27   And generate this:  ES.001    119.55 ES.073     17.95 ES.140     53.88 ES.178    150.27   Is there a way of doing this from a bash command-line?
107704
I have data like multiples of 40. 40 80 120 160 200 and so on.    I would like to label every record that is a multiple of 100.  I have tried a couple of methods and can't get them to work either as a query in the label or as a select statement.  "STATION" =  %00   RIGHT ("STATION", 2) =  00     I get invalid SQL statement. Does anyone see what I am doing wrong?    Respectfully I did search and did not see any of the example questions you presented.  However it still does not answer my question, re-stated, what am I doing wrong?
67515
Ok, here is my dilemma I have a database set up with about 5 tables all with the exact same data structure. The data is separated in this manner for localization purposes and to split up a total of about 4.5 million records.  A majority of the time only one table is needed and all is well. However, sometimes data is needed from 2 or more of the tables and it needs to be sorted by a user defined column. This is where I am having problems.  data columns:  id, band_name, song_name, album_name, genre   MySQL statment:  SELECT * from us_music, de_music where `genre` = 'punk'   MySQL spits out this error:  #1052 - Column 'genre' in where clause is ambiguous   Obviously, I am doing this wrong. Anyone care to shed some light on this for me?
2625
What is the best way to remove duplicate rows from a fairly large SQL Server table (i.e. 300,000+ rows)?  The rows, of course, will not be perfect duplicates because of the existence of the RowID identity field.  MyTable  RowID int not null identity(1,1) primary key, Col1 varchar(20) not null, Col2 varchar(2048) not null, Col3 tinyint not null
2551
Table:   UserId, Value, Date.   I want to get the UserId, Value for the max(Date) for each UserId. That is, the Value for each UserId that has the latest date. Is there a way to do this simply in SQL? (Preferably Oracle)  Update: Apologies for any ambiguity: I need to get ALL the UserIds. But for each UserId, only that row where that user has the latest date.