I want to split table in bins and then select random 1000 rows from each splitted table and join these rows to final table.
in pyspark i can do like this
df1 = (df.where((df.A >1)&(df.A <10)))
df1=df1.orderBy(F.rand()).limit(1000)
df2 = (df.where((df.A >10)&(df.A <20)))
df2=df2.orderBy(F.rand()).limit(1000)
dfs = [df1, df2]
df_complete = reduce(DataFrame.unionAll, dfs)
how to do this in sql ?