Sql dolphindb支持列表查询吗?
我想立即应用下面的一组SQL语句,并结合结果来获得mt=52355979之后不同交易场所和市场类型(由“c1”、“c2”、“c3”、“c4”标识)的各种股票(由“symbol”标识)的最新记录Sql dolphindb支持列表查询吗?,sql,database,dolphindb,Sql,Database,Dolphindb,我想立即应用下面的一组SQL语句,并结合结果来获得mt=52355979之后不同交易场所和市场类型(由“c1”、“c2”、“c3”、“c4”标识)的各种股票(由“symbol”标识)的最新记录 从t中选择*,其中symbol=`A,c1=25,c2=814,c3=11,c4=2,date=2020.02.05,mt您可以定义如下函数 def bundleQuery(tbl, dt, dtColName, mt, mtColName, filterColValues, filterColNames
从t中选择*,其中symbol=`A,c1=25,c2=814,c3=11,c4=2,date=2020.02.05,mt您可以定义如下函数
def bundleQuery(tbl, dt, dtColName, mt, mtColName, filterColValues, filterColNames){
cnt = filterColValues[0].size()
filterColCnt =filterColValues.size()
orderByCol = sqlCol(mtColName)
selCol = sqlCol("*")
filters = array(ANY, filterColCnt + 2)
filters[filterColCnt] = expr(sqlCol(dtColName), ==, dt)
filters[filterColCnt+1] = expr(sqlCol(mtColName), <, mt)
queries = array(ANY, cnt)
for(i in 0:cnt) {
for(j in 0:filterColCnt){
filters[j] = expr(sqlCol(filterColNames[j]), ==, filterColValues[j][i])
}
queries.append!(sql(select=selCol, from=tbl, where=filters, orderBy=orderByCol, ascOrder=false, limit=1))
}
return loop(eval, queries).unionAll(false)
}
def bundleQuery(tbl, dt, dtColName, mt, mtColName, filterColValues, filterColNames){
cnt = filterColValues[0].size()
filterColCnt =filterColValues.size()
orderByCol = sqlCol(mtColName)
selCol = sqlCol("*")
filters = array(ANY, filterColCnt + 2)
filters[filterColCnt] = expr(sqlCol(dtColName), ==, dt)
filters[filterColCnt+1] = expr(sqlCol(mtColName), <, mt)
queries = array(ANY, cnt)
for(i in 0:cnt) {
for(j in 0:filterColCnt){
filters[j] = expr(sqlCol(filterColNames[j]), ==, filterColValues[j][i])
}
queries.append!(sql(select=selCol, from=tbl, where=filters, orderBy=orderByCol, ascOrder=false, limit=1))
}
return loop(eval, queries).unionAll(false)
}
dt = 2020.02.05
dtColName = "dsl"
mt = 52355979
mtColName = "mt"
colNames = `symbol`c1`c2`c3`c4
colValues = [50982208 50982208 51180116 41774759, 25 25 25 1180, 814 814 814 333, 11 12 12 3, 2 2 2 116]
bundleQuery(t, dt, dtColName, mt, mtColName, colValues, colNames)