question

gmi georges avatar image
0 Likes"
gmi georges asked Sebastian Hemmann commented

ROW_NUMBER as a SQL keyword

How to use this keyword ? Example ?

FlexSim 17.1.1
query
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jacob Gillespie avatar image
4 Likes"
Jacob Gillespie answered Sebastian Hemmann commented

Let's say you have a table like this:

The following query would give you all the columns of row 1:

Table result = Table.query("SELECT * FROM GlobalTable1 WHERE ROW_NUMBER = 1");

And this query would give you the row numbers of rows where Col 1 has a value of 1:

Table result = Table.query("SELECT ROW_NUMBER FROM GlobalTable1 WHERE [Col 1] = 1");

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

anthony.johnson avatar image anthony.johnson ♦♦ commented ·

Also, ROW_NUMBER works like any other field name, in that you can use SQL's dot syntax to clarify the desired table when doing inner joins:

SELECT Customers.CustomerID, 
	Orders.OrderID, 
	Orders.ROW_NUMBER, 
	Customers.ROW_NUMBER 
FROM Customers INNER JOIN Orders ON Orders.CustomerID = Customers.CustomerID

It's as if every table has a "hidden" column named ROW_NUMBER with a value that corresponds to the associated row of the table.

1 Like 1 ·
Sebastian Hemmann avatar image Sebastian Hemmann anthony.johnson ♦♦ commented ·

@anthony.johnson Could you probably also add an easy example how this works, if I want to return the Row number of a specific row of my Table depending on the Result Table I´ve created?

0 Likes 0 ·