I am trying to export a table from Bigquery to single file in GCS. But my output is not in sorted order.
export data options(uri = 'gs://<bucket><object>/file1_*.csv', format = 'CSV',overwrite = true, header = true, field_delimiter = '|') as select distinct * from (select * from table1 where country not in (select distinct(country) from table2) order by col_rnk)
distinct * has been used to get the output into single file in GCS.
Any help would be great !
i think you should move
ORDER BY col_rnkout side .with that please try the below
NOT THE PART OF ANSWER TO THE ABOVE QUESTION BUT TO DRAWN ATTANTATION TO THE FOLLOWING POINTS.
please take a look at query-syntax#select_distinct
also can you verify the logic and try without the uses of
SELECT DISTINCT *please consider the following approach