Introduction
The challenge involves validating the GUID values and perform horizontal and vertical
count of the characters "1, 2, 3, 4, 5, A, B, C, D, E".
The definition of valid GUID is "The GUID value should contain all the characters
1, 2, 3, 4, 5, A, B, C, D, E".
e.g. In "7FC61235-F252-4E32-BD31-99FB1FC8A574" all the characters given in character
set are present while in "7FX61235-X252-4Y32-BZ31-99FB1FC8Z574" some of them are
missing even though they both are GUIDs. So the program should accept "7FC61235-F252-4E32-BD31-99FB1FC8A574"
as a valid GUID.
A typical GUID looks like 704A9279-B245-4D4E-9616-7ACB6E9DF7A0.
Sample Data
Guid
------------------------------------
7FC61235-F252-4E32-BD31-99FB1FC8A574
D031BC00-ADD3-4C40-BE24-A613586FD42C
81B10B95-5A22-4D3A-949A-FF268103A554
ABCDE12345E
Expected Results
ValidGuid 1 2 3 4 5 A B C D E H Sum
------------------------------------ - - - - - - - - - - -----
7FC61235-F252-4E32-BD31-99FB1FC8A574 3 4 3 2 3 1 2 2 1 1 22
D031BC00-ADD3-4C40-BE24-A613586FD42C 2 2 3 4 1 2 2 3 4 1 24
Vertical Sum 5 6 6 6 4 3 4 5 5 2 46
Rules
- Output should be sorted in Ascending Order of ValidGuid.
- Consider the character count for only the characters 1,2,3,4,5,A,B,C,D,E.
- The output should be formatted as shown in 'Expected Result'.Column name should
be exactly the same and the result must be sorted in Ascending order of ValidGuid.
Sample Script
Use the following script to generate the sample data.
DECLARE @t TABLE(Guid VARCHAR(50))
INSERT INTO @t
SELECT '7FC61235-F252-4E32-BD31-99FB1FC8A574' UNION ALL
SELECT 'D031BC00-ADD3-4C40-BE24-A613586FD42C' UNION ALL
SELECT '81B10B95-5A22-4D3A-949A-FF268103A554' UNION ALL
SELECT 'ABCDE12345E'
SELECT * FROM @t
Restrictions
- The solution should be a single query that starts with a "SELECT" or “;WITH”.
Notes
Tags:Puzzles, TSQL Beginners Challenge, TC, TSQL Beginners Challenge 13