DECLARE @test table (code char(5)) INSERT INTO @test VALU...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Puzzling

Q&A for those who create, solve, and study puzzles

DECLARE @test table
(code char(5))
INSERT INTO @test
VALUES ('1ABCD')
SELECT *, LEFT(code, 1), SUBSTRING(code, 2, 1), SUBSTRING(code, 3, 1), SUBSTRING(code, 4, 1), SUBSTRING(code, 5, 1) FROM @test
DECLARE @test2 table
(line int,
rev char(4),
code char(5),
unit int,
dos date)
INSERT INTO @test2
VALUES
(1,'0023','1ABCD',1, '20180601'),
(2,'0420','G0151',4, '20180601'),
(3,'0420','G0151',2, '20180605'),
(4,'0430','G0152',3, '20180601'),
(5,'0440','G0153',4, '20180606'),
(6,'0570','G0156',3, '20180608'),
(7,'0440','G0153',4, '20180615'),
(8,'0420','G0151',5, '20180607'),
(9,'0430','G0152',6, '20180608'),
(10,'0430','G0152',4, '20180609'),
(11,'0550','G0162',3, '20180620'),
(12,'0550','G0162',2, '20180612'),
(13,'0550','G0163',5, '20180622')
SELECT * FROM @test2

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results