It really depends, but I generally suggest using some sort of data prep tool before you get into Tableau Desktop. You could use Tableau Prep for instance. Use that tool to perform the operations, instead of complex SQL, then present nice clean data to Desktop.
Thanks for replying. If I don't use any Data Prep then in such case how would I handle complex sql queries? If in case the data is a very one then, how it is to be sorted? Please let me know. Many thanks!
You can use custom SQL in Tableau: Connect to a Custom SQL Query - Tableau
Or you could write the SQL and save it as a view in the database then connect to the view.
Or you could build a stored procedure in SQL and connect to the SP.