sql,查询语句怎么写,返回入库时间,表(日期,数量) 10
1个回答
2017-08-23
展开全部
sql,查询语句怎么写,返回入库时间,表(日期,数量)
SELECT top 1 t1.in_date
FROM test1 t1
LEFT JOIN test1 t2
ON t1.in_date >= t2.in_date
AND t1.qty > 0
GROUP BY t1.in_date
HAVING SUM(t2.qty) > 150
ORDER BY in_date
-- output:
-- 20140408
SELECT top 1 t1.in_date
FROM test1 t1
LEFT JOIN test1 t2
ON t1.in_date >= t2.in_date
AND t1.qty > 0
GROUP BY t1.in_date
HAVING SUM(t2.qty) > 150
ORDER BY in_date
-- output:
-- 20140408
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询