You are here

Oracle

How to select records with given interval

Blog Terms: 
How to select records with every N records' interval?
Using the rank(), this is the the snipet, for Oracle:
Table name: tableabc,
---------------------
id  |  time  |   test
---------------------
SELECT id, rank() over (partition by 1 order by time) as interval, test
                                   FROM  tableabc 

Oracel SQL, use ROW_NUMBER() to filter same records when JOIN tables

Blog Terms: 

Sometimes we will retrieve repetitive records when we use JOIN to join tables.
Now distinct, group by, and Having will not work, ROW_NUMBER() is a good choice.

for example:

select a.one, b.two from A a
LEFT JOIN B b ON a.id = G.id where where a.name like '%abc%' and a.time < 1234545;

using ROW_NUMBER() after

SELECT ROWNUM, C* FROM(
SELECT a.id, a.one, b.two, b.id,
ROW_NUMBER() OVER(PARTITION BY a.id ORDER BY a.time DESC) AS ROW_FLG
FROM (select * from A where name like '%abc%' and time < 1234545) a
LEFT JOIN B b ON a.id=b.id
ORDER BY a.time DESC

SQL code snipet, join multi-tables with one column

Blog Terms: 

3 tables(CHART_TEST, CHART_TEST1, CHART_TEST2) need be joined with continious timestamb:

 ID    TIMESTAMP    VALUE
     1    115    456
     4    130    671
     5    190    135
     8    150    934
     9    160    296
     2    120    356
     3    125    556
     6    140    213
     7    145    363
     10    165    358

Oracle and java.sql.SQLException: No suitable driver

Blog Terms: 

Strange problem, just one part of simple code, works on my XP system, but not on Windows2003.

Connection connection=null;
try{
connection = DriverManager.getConnection ("jdbc:odbc:thin@192.168.2.107:1521:Schemaname", "username", "password");
PreparedStatement pstmt = con.prepareStatement ("Select * from sometable");
ResultSet rset = pstmt.executeQuery();
....................

Very simple SQL code for one servlet, but when i run it in Tomcat, i got this exception:

java.sql.SQLException: No suitable driver found for

Subscribe to RSS - Oracle