Issue: Change the symbol point (.) in the following string ". 1.2.3.4.5.6.7.8.9 = 1" to symbol plus (+) or symbol (-), how many methods are there? Please use SQL to resolve this issue
calculation process:
CREATE TABLE# (VALINT)INSERT into #SELECT 1 UNION AllSELECT 2 UNION AllSELECT 3 UNION AllSELECT 4 UNION AllSELECT 5 UNION AllSELECT 6 UNION AllSELECT 7 UNION AllSELECT 8 UNION AllSELECT 9 CREATE TABLE#1(VALCHAR(1))INSERT into#1SELECT '+' UNION AllSELECT '-'; withA as(SELECT#1. VAL val1,#. VAL from#JOIN#1 on 1=1)SELECT RTRIM(A1. VAL1)+RTRIM(A1. VAL)+RTRIM(A2. VAL1)+"'+RTRIM(A2. VAL)+RTRIM(A3. VAL1)+"'+RTRIM(A3. VAL)+RTRIM(A4. VAL1)+"'+RTRIM(A4. VAL)+RTRIM(A5. VAL1)+"'+RTRIM(A5. VAL)+RTRIM(A6. VAL1)+"'+RTRIM(A6. VAL)+RTRIM(A7. VAL1)+"'+RTRIM(A7. VAL)+RTRIM(A8. VAL1)+"'+RTRIM(A8. VAL)+RTRIM(A9. VAL1)+"'+RTRIM(A9. VAL) Result fromA a1,a a2,a a3,a a4,a a5,a a6,a a7,a a8,a A9WHEREA1. VAL=1 andA2. VAL=2 andA3. VAL=3 andA4. VAL=4 andA5. VAL=5 andA6. VAL=6 andA7. VAL=7 andA8. VAL=8 andA9. VAL=9 and Case whenA1. VAL1='-' Then -A1. VALELSEA1. VALEND+ Case whenA2. VAL1='-' Then -A2. VALELSEA2. VALEND+ Case whenA3. VAL1='-' Then -A3. VALELSEA3. VALEND+ Case whenA4. VAL1='-' Then -A4. VALELSEA4. VALEND+ Case whenA5. VAL1='-' Then -A5. VALELSEA5. VALEND+ Case whenA6. VAL1='-' Then -A6. VALELSEA6. VALEND+ Case whenA7. VAL1='-' Then -A7. VALELSEA7. VALEND+ Case whenA8. VAL1='-' Then -A8. VALELSEA8. VALEND+ Case whenA9. VAL1='-' Then -A9. VALELSEA9. VALEND=1
Execution Result:
SQL Puzzles (add and subtract symbol overrides)