How can I build a dynamic WHERE clause efficiently?
I need to build a WHERE clause dynamically based on the filters a user selects, such as a date range, a list of stock symbols, or a price range. I’m using DolphinDB’s sql function to construct and evaluate the query. t = table( take(2025.01.01..2025.01.05, 100) as date, take(`A`B`C`D`E, 100) as sym, rand(100.0, 100) as price ) // Filter expressions dateFilter = expr(parseExpr("date >= 2025.01.03")) symFilter = expr(parseExpr("sym in `A`B`C")) // Construct and evaluate the query dynamicSQL = sql(select=t, where=<[date >= 2025.01.03, sym in `A`B`C]>) result = dynamicSQL.eval() In my tests, this
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.