Sql questions Question 1



Yüklə 67,59 Kb.
səhifə2/4
tarix23.12.2023
ölçüsü67,59 Kb.
#156483
1   2   3   4
6afac0bf-38b2-49c5-88da-a3701e407493 5 puzzles

Question 4:


Write an SQL statement that counts the consecutive values in the Status field.
Input:

Output:

DDL:
DROP TABLE IF EXISTS #Groupings;

CREATE TABLE #Groupings


(
StepNumber INTEGER PRIMARY KEY,
TestCase VARCHAR(100) NOT NULL,
[Status] VARCHAR(100) NOT NULL
);
INSERT INTO #Groupings (StepNumber, TestCase, [Status])
VALUES
(1,'Test Case 1','Passed'),
(2,'Test Case 2','Passed'),
(3,'Test Case 3','Passed'),
(4,'Test Case 4','Passed'),
(5,'Test Case 5','Failed'),
(6,'Test Case 6','Failed'),
(7,'Test Case 7','Failed'),
(8,'Test Case 8','Failed'),
(9,'Test Case 9','Failed'),
(10,'Test Case 10','Passed'),
(11,'Test Case 11','Passed'),
(12,'Test Case 12','Passed');

Question 5:


You are given the following list of test cases and must determine all possible permutations. Write an SQL statement that produces the expected output. Ensure your code can account for a changing number of elements without rewriting.

DDL:
DROP TABLE IF EXISTS #TestCases;

CREATE TABLE #TestCases


(
TestCase VARCHAR(1) PRIMARY KEY
);

INSERT INTO #TestCases (TestCase) VALUES


('A'),('B'),('C');

Python Questions


Question 1: Reverse String


Write a Python program that prompts the user to enter a string and then prints the reversed version of that string. For example, if the user enters "Hello, World!", the program should output "!dlroW ,olleH". Ensure that your program handles the user's

Question 2: Missing Number


You are given a list containing n distinct numbers taken from the range 0 to n. The list has one number missing. Write a Python function to find and return the missing number.
For example:
missing_number([3, 0, 1])
# Output: [2]


missing_number([9, 6, 4, 2, 3, 12, 5, 7, 0, 1])
# Output: [8, 10, 11]
Rules:

  1. The list will contain distinct integers.

  2. The missing number is guaranteed to be in the range 0 to n.

  3. The list can be of any length.



Yüklə 67,59 Kb.

Dostları ilə paylaş:
1   2   3   4




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə