Tableau wraps a custom SQL statement in a nested sub-statement when issuing against standard relational database sources.
You could include the ORDER BY so long as you also include the rownum limit there as well.
May I ask why you even need the data source to be ordered?
You can always control ordering in the visualization layer of whatever you build in Tableau.
Don't use Order By in custom SQL. How the data ends up in the resulting database has no order how Tableau queries this result later on for the rest of your workbook. When using fields you can change the sort order for each of these as you wish.
thanks for your answer but I really need to perform the "order by" in the custom sql to retrieve the right date
the result shall be
tab1.x tab1.y tab1.date tab2.date
tab1 and tab2 are alias for the same table in DB
do you have a clue ?.
Oracle SQL is not my strong suit.
In SQL Server, it be possible to re-write this query a number of ways that do not require the ORDER BY clause.
You'll have to flex your SQL-writing muscles.
You need to either specify the rownum criteria (which makes the ORDER BY syntax necessary) or re-write without an ORDER BY in your outermost select.
Can you just set a WHERE rownum = n so that n is more records than you'll ever need to retrieve?
I don't if I am clear
I have a table containing diferent kinds of events and the data of events.
evt1 event type 1 date1
evt2 event type 2 date2
evt3 event type 1 date3
evt4 event type 2 date4
evt5 event type 1 date5
evt6 event type 2 date6
I would like to have as result of my custom sql
evt1 event type 1 date1 evt2 event type 2 date2 ==> retrieve the following event with a diferent event type
evt3 event type 1 date3 evt4 event type 2 date4 ==> retrieve the following event with a diferent event type
evt5 event type 1 date5 evt6 event type 2 date6 ==> retrieve the following event with a diferent event type
to build a report in which I will have
evt1 evt2 date1 - date2
evt3 evt4 date3 - date4
evt5 evt6 date5 - date6
How do you establish that Event 1 and Event 2 are related?
There should be a join criteria from data set 1 to data set 2 where they both share something in common, right?
yes it is right
the event 1 and event 2 are store in the same table and the join is on the field user
for each event whose even type is 1 I need to retrieve the following ( in term of date) event whose even type is 2