以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]SQL同表合并问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=178445) |
-- 作者:dj68301367 -- 发布时间:2022/7/5 11:25:00 -- [求助]SQL同表合并问题 Dim tb As Table = Tables(e.Form.Name & "_Table1") Dim cmd As New SQLCommand cmd.C Dim fi As String = " and 仓库名称 = \'" & e.Form.Controls("Comb仓库选择").text & "\' and JCCDate BETWEEN \'" & e.Form.Controls("Date开始日期").Value & "\' and \'" & e.Form.Controls("Date结束日期").Value & "\'" cmd.CommandText = "SELE CT JCCDate,SUM(JCC数量) AS 进仓数量, 0 as 出仓数量 FROM {KC_JCCMX} where jcc数量 > 0 " & fi & " GROUP BY JCCDate union all " cmd.CommandText &= "SEL ECT JCCDate,0 as 进仓数量,SUM(JCC数量) AS 出仓数量 FROM {KC_JCCMX} where jcc数量 < 0 " & fi & " GROUP BY JCCDate " tb.DataSource = cmd.ExecuteReader Dim sdt As DataTable = cmd.ExecuteReader [此贴子已经被作者于2022/7/5 14:10:16编辑过]
|