1

I've got software where I can provide SQL queries to db. But there is limitation, I can only change WHERE clause... for ex.: [Python] x = gp.searchcursor('DATABASE_NAME','FIELDS WHICH I WANT TO VIEW','WHERE_CLAUSE')

I've got table where is about ~250k records and I want to get first 50-70 (number doesnt matter) of records. My question is how can I create query (actually WHERE clause) which will return mi those records?

just for clarify, on the bottom of application there is Oracle and MS SQL server (depends of called database)

Krystian
  • 458
  • 1
  • 9
  • 26

1 Answers1

2

Maybe you can do the trick using a subquery in WHERE

WHERE YourID IN (SELECT TOP 50 YourID FROM YourTable WHERE YourActualConditions)

This will work for SQL Server, Oracle syntax is slightly different:

WHERE YourID IN (SELECT YourID FROM YourTable WHERE YourActualConditions AND ROWNUM<=50)

EDIT Actually in Oracle you wouldn't even need a subquery:

 WHERE YourActualConditions AND ROWNUM<=50

should be enough

Nenad Zivkovic
  • 18,221
  • 6
  • 42
  • 55