Linked Questions

2 votes
3 answers
5k views

I've got a table with a few columns, and for each row I want the maximum: -- Table: +----+----+----+----+----+ | ID | C1 | C2 | C3 | C4 | +----+----+----+----+----+ | 1 | 1 | 2 | 3 | 4 | | 2 | ...
Gregor Thomas's user avatar
-6 votes
2 answers
33k views

I need to fetch the maximum value from multiple columns in a single row. The row looks like this: Col1 || Col2 || Col3 || Col4 || 100 || 120 || 130 || 140 || 100 || 130 || 130 || 140 || 100 |...
Ankur M's user avatar
  • 31
-1 votes
1 answer
9k views

I have a table with several date fields. I need to get a derived field that is the oldest date of 3 particular fields. I have to do this for 4 different date sets.
shorton's user avatar
  • 353
3 votes
4 answers
1k views

SQL (SQL Server) How to find maximum value among different columns in a single Table Row returned by a SQL Query. Select Maximum(table.column1,table.column2,table.column3,...) as 'MaximumValue' ...
user2625470's user avatar
5 votes
7 answers
537 views

ID Date1 Date2 Date3 158 5/3/13 15:11 2/20/13 11:38 2/20/13 11:38 I want to get the latest date from this three columns.
user3619447's user avatar
2 votes
3 answers
414 views

SQL Isn't my Forte, Some help from you experts would be amazing :) Dataset: Name of Product | Part Number | Size 1 | Size 2 | Size 3 ------------------|----------------|-----------|--------...
John Doe's user avatar
-2 votes
2 answers
632 views

I was asked to find the largest number from the table (including all rows and columns) using SQL. Here is the sample data. It should return 90 as the largest number. row1 row2 row3 10 20 ...
Paras Gupta's user avatar
-1 votes
2 answers
201 views

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!
CLab's user avatar
  • 3
-1 votes
1 answer
130 views

I have a table with following data villageId ChildID VC1_date VC2_date VC3_date VC4_date VC5_date ---------------------------------------------------------------------------- 1 ...
Zulqarnain Jalil's user avatar
0 votes
0 answers
82 views

Say there is a table with columns of such: date1, date2, date3, val1, val2, val3 2017-02-28, 2017-01-01, 2017-01-02, 100, 200, 300 2016-05-09, 2016-09-09, 2016-05-04, 2, 10, 20 I would like to get ...
superuserDoHaveStupidQ's user avatar
-2 votes
2 answers
55 views

How Can I get the max value from few columns for each table row? ID Date1 Date2 ----------- ---------- ---------- 1 2019-01-01 2019-12-29 result: ID MaxDate ...
Michal's user avatar
  • 9
0 votes
0 answers
31 views

So, I got myself in a situation where I have 36 columns and need to essentially do a "MIN" on ALL those columns. Not a MIN by grouping, rather, what I need is what the 2022-and-after LEAST ...
Isaac's user avatar
  • 17
658 votes
31 answers
718k views

I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o But this isn't how the MAX function works, right? It is an aggregate function so it expects ...
skb's user avatar
  • 31.3k
52 votes
13 answers
7k views

I use SQL Server 2008 R2. I need to sort a table by the minimal value of two columns. The table looks like this: ID: integer; Date1: datetime; Date2: datetime. I want my data to be sorted by ...
Vasiliy Volkov's user avatar
81 votes
4 answers
51k views

I'm trying to select the max date in three different fields in each record (MySQL) So, in each row, I have date1, date2 and date3: date1 is always filled, date2 and date3 can be NULL or empty The ...
Ivan's user avatar
  • 2,501

15 30 50 per page
1
2 3 4 5