I would like to copy a certain range within q SQL table and input into new table. I also need to exclude part of the results.
I have seen on some forums and some SQL tutorial websites that they mostly use BETWEEN STATEMENT but this only can use in single condition.
My condition is copy the certain range with 2 conditions such as start copy with specific
part number and end with
type that is "A" but this data must be after ,so it can be a range.
UPDATED-- Below Link is the full question.
How to exclude a certain range in SQL results? - Stack Overflow[^]
Thanks All.
[EDIT - one way of showing sample data]
NO TYPE Part Quantity other
1 Z 1001 1
2 A 1002 1
3 T 1003 1
4 C 1004 1
5 F 1005 1
6 V 1006 1
7 C 1007 1
8 B 1008 1
9 D 1009 1
10 S 1010 1
11 V 1011 1
12 Z 1012 1
13 X 1013 1
14 A 1014 1
15 H 1015 1
16 V 1016 1
17 L 1017 1
18 A 1018 1
Another way of showing some sample data
create table demo (NO int identity(1,1)
, TYPE char(1)
, Part int
, Quantity int
, other varchar(10) NULL)
insert into demo (TYPE, Part, Quantity) VALUES
('Z', 1001, 1 ),
('A', 1002, 1 ),
('T', 1003, 1 ),
('C', 1004, 1 ),
('F', 1005, 1 ),
('V', 1006, 1 ),
('C', 1007, 1 ),
('B', 1008, 1 ),
('D', 1009, 1 ),
('S', 1010, 1 ),
('V', 1011, 1 ),
('Z', 1012, 1 ),
('X', 1013, 1 ),
('A', 1014, 1 ),
('H', 1015, 1 ),
('V', 1016, 1 ),
('L', 1017, 1 ),
('A', 1018, 1 )
Expected results
NO TYPE Part Quantity other
2 A 1002 1
3 T 1003 1
4 C 1004 1
5 F 1005 1
6 V 1006 1
7 C 1007 1
8 B 1008 1
9 D 1009 1
10 S 1010 1
11 V 1011 1
12 Z 1012 1
13 X 1013 1
14 A 1014 1
What I have tried:
I have seen on some forums and some SQL tutorial websites