Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

in-DB Limit top 100 rows

cjsnets10
6 - Meteoroid

Hi Everyone,

 

I am using the in-DB tool to grab a massive data set from a database. While I am building the work flow I would like to limit the record to the top 100 for efficiency.

I see there is a SQL Editor that can be used, but unfortunately I do not know SQL at all. The black line provides the table name. I tried using TOP and LIMIT, but I feel I am using them in the wrong way.

 

Cjsnets10_0-1664542839275.png

 

6 REPLIES 6
DataNath
17 - Castor
17 - Castor

Hey @cjsnets10, how did you try using TOP? Should look something like:

 

SELECT TOP (100) *

FROM <Insert Table Name>
cjsnets10
6 - Meteoroid

@DataNath I tried and this came up

 

Cjsnets10_0-1664543355604.png

 

Felipe_Ribeir0
16 - Nebula

Hi @cjsnets10 

 

Do you know which DB you are connecting with?

 

For example, using SQL Server you will do something like

SELECT TOP 3 * FROM Customers;
 
MySQL
SELECT * FROM Customers
WHERE Country='Germany'
LIMIT 3;
 
Oracle
SELECT * FROM Customers
WHERE Country='Germany'
FETCH FIRST 3 ROWS ONLY;

 

Take a look at this link:

https://www.w3schools.com/sql/sql_top.asp

 

cjsnets10
6 - Meteoroid

I am connecting to Vertica.

DataNath
17 - Castor
17 - Castor

If you're using Vertica then it looks like you'll want to use LIMIT then: https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Statements/SELECT/LIMIT...

 

SELECT * FROM <Table Name Here>

LIMIT 100

 

From the documentation it looks like that will bring through a random 100 results each time you run the query and so if you want a consistent set of results you'll need something like:

 

SELECT * FROM <Table Name Here>

ORDER BY <Insert a field to order by>

LIMIT 100

Felipe_Ribeir0
16 - Nebula

@cjsnets10 Ok, so based on my previous response, i would take a look how this is done in Vertica and try something like this:

SELECT * FROM table LIMIT 100;

https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Statements/SELECT/LIMIT...

 

Labels
Top Solution Authors