我目前有一个非常大的Excel工作表,包含大量的VBA,我想进入Access,如果可能的话,使用查询而不是一堆循环,if语句等来加速它。现在的主要停止点正在处理订单数据。
数据以类似于下面的格式下载(我已经大大简化了它):
Order Number Operation Sequence
A1 0 1
A1 0 2
A1 L 3
A2 L 1
A3 L 1
A4 0 1
A4 L 2
在Excel中,我可以使用订单号循环遍历行,并在操作为" L"时停止。我想使用订单号浏览每一行,并在第一行" L"之后删除所有其他序列。到达了。顶级表的预期回报是:
entity CarrySelect is
port( a : in std_logic_vector(7 downto 0);
b : in std_logic_vector(7 downto 0);
s : out std_logic_vector(7 downto 0);
co : out std_logic;
ci : in std_logic
);
end CarrySelect;
architecture behav of CarrySelect is
component multiplexer2 is
port (
a : in std_logic;
b : in std_logic;
s : in std_logic;
y : out std_logic
);
end component;
component RCA4 is --add RCA4 component for use by CS adder
port (ci: in std_logic;
a, b: in std_logic_vector(3 downto 0);
s: out std_logic_vector(3 downto 0);
co: out std_logic
);
end component;
signal t0,t1,c0,c1 : std_logic_vector(7 downto 0); --temp signals for passing from RCAs to muxes
signal co1 : std_logic;
begin
--for carry 0
RCA0 : RCA4 port map('0', a(3 downto 0), b(3 downto 0), t0(3 downto 0), c0(0));
RCA2 : RCA4 port map('0', a(7 downto 4), b(7 downto 4), t0(7 downto 4), c0(1));
--for carry 1
RCA1 : RCA4 port map('1', a(3 downto 0), b(3 downto 0), t1(3 downto 0), c1(0));
RCA3 : RCA4 port map('1', a(7 downto 4), b(7 downto 4), t1(7 downto 4), c1(1));
--mux for carry
MUX0 : multiplexer2 port map(c0(0),c1(0),ci,co1);
MUX9 : multiplexer2 port map(c0(1),c1(1),co1,co);
--muxes for sum
MUX1 : multiplexer2 port map(t0(0),t1(0),ci,s(0));
MUX2 : multiplexer2 port map(t0(1),t1(1),ci,s(1));
MUX3 : multiplexer2 port map(t0(2),t1(2),ci,s(2));
MUX4 : multiplexer2 port map(t0(3),t1(3),ci,s(3));
MUX5 : multiplexer2 port map(t0(4),t1(4),co1,s(4));
MUX6 : multiplexer2 port map(t0(5),t1(5),co1,s(5));
MUX7 : multiplexer2 port map(t0(6),t1(6),co1,s(6));
MUX8 : multiplexer2 port map(t0(7),t1(7),co1,s(7));
end architecture behav;
空白/缺失行应从表中删除。
答案 0 :(得分:1)
我没有测试过这个,但它会给你一个很好的起点。它假设您的Access表已使用RecordID主键正确导入:
DELETE * FROM OrderData WHERE RecordID IN (
SELECT RecordID FROM OrderData INNER JOIN
(SELECT OrderNumber, MIN(Sequence) AS LGS FROM OrderData WHERE Operation='L' GROUP BY OrderNumber) LGR
ON OrderData.OrderNumber=LGR.OrderNumber AND OrderData.Sequence>LGR.LGS )
它的作用是首先得到MIN(序列)与' L'每个订单号的操作,然后获取Sequence高于该值的所有RecordID,并将其用作DELETE条件。