SQL statement
-
Hello..i want to ask question. In my database there is a column for Date such as below: 2014-03-26 2014-03-25 2014-03-24 Does anyone know how I want to retrieve data value from a previous row with select statement.If I want the latest data, so the sql is like this ORDER BY Actuators.Date DESC";and the answer I get is 2014-03-26. But if I want to show the previous data value from previous row what can I do?The result will show date 2014-03-25. Tq
-
Hello..i want to ask question. In my database there is a column for Date such as below: 2014-03-26 2014-03-25 2014-03-24 Does anyone know how I want to retrieve data value from a previous row with select statement.If I want the latest data, so the sql is like this ORDER BY Actuators.Date DESC";and the answer I get is 2014-03-26. But if I want to show the previous data value from previous row what can I do?The result will show date 2014-03-25. Tq
Which database system? SQL Server 2012? You want to get the second highest? Or both the highest and second-highest in one row?
You'll never get very far if all you do is follow instructions.
-
Hello..i want to ask question. In my database there is a column for Date such as below: 2014-03-26 2014-03-25 2014-03-24 Does anyone know how I want to retrieve data value from a previous row with select statement.If I want the latest data, so the sql is like this ORDER BY Actuators.Date DESC";and the answer I get is 2014-03-26. But if I want to show the previous data value from previous row what can I do?The result will show date 2014-03-25. Tq
-
Which database system? SQL Server 2012? You want to get the second highest? Or both the highest and second-highest in one row?
You'll never get very far if all you do is follow instructions.
Database system is SQL Server 2012. I just want to get the second highest in a column Date.
-
Database system is SQL Server 2012. I just want to get the second highest in a column Date.
You could use ROW_NUMBER and select the one with a value of 2. Or something like:
SELECT TOP(1) * FROM (
SELECT TOP(2) StartTime FROM dbo.RunSummary ORDER BY StartTime DESC
) T ORDER BY StartTimeNeither seems very elegant.
You'll never get very far if all you do is follow instructions.
-
You could use ROW_NUMBER and select the one with a value of 2. Or something like:
SELECT TOP(1) * FROM (
SELECT TOP(2) StartTime FROM dbo.RunSummary ORDER BY StartTime DESC
) T ORDER BY StartTimeNeither seems very elegant.
You'll never get very far if all you do is follow instructions.
Tqvm :)
-
yes..it working! ;)
-
Hello..i want to ask question. In my database there is a column for Date such as below: 2014-03-26 2014-03-25 2014-03-24 Does anyone know how I want to retrieve data value from a previous row with select statement.If I want the latest data, so the sql is like this ORDER BY Actuators.Date DESC";and the answer I get is 2014-03-26. But if I want to show the previous data value from previous row what can I do?The result will show date 2014-03-25. Tq