sql >> Database >  >> RDS >> Oracle

selecteer 2e rij in Plsql

CREATE TABLE mytable (id NUMBER PRIMARY KEY, price NUMBER NOT NULL);
INSERT INTO mytable VALUES (1, 10);
INSERT INTO mytable VALUES (2, 20);
INSERT INTO mytable VALUES (3, 20);
INSERT INTO mytable VALUES (4, 30);

SELECT id, price 
 FROM (
       SELECT id, price, RANK() OVER (ORDER BY price DESC) AS r
         FROM mytable
      )
 WHERE r=2;

 ID PRICE
--- -----
  2    20
  3    20


  1. SonarQube:Hoe kan de grootte van maatregelen_data.ibd worden verkleind?

  2. poortnummer van de mysql-server

  3. T-SQL-bugs, valkuilen en best practices – determinisme

  4. Verberg inloglink wanneer ingelogd