Home > database > SQL server genuflect is begged the statement which practice (complex)
SQL server genuflect is begged the statement which practice (complex)
Time:10-29
My SQL language is not very good, so want to exercise, which eldest brother or sister, and such questions? I want to practice
CodePudding user response:
- 1. The build table The CREATE TABLE # T ( Id INT, [name] VARCHAR (10), [for] INT, [left] INT, [right] INT ) - 2. Insert the data INSERT INTO # T VALUES (1, 'a little', 0, 3, 2) INSERT INTO # T VALUES (4, 'smiled, 2, 8, 9) INSERT INTO # T VALUES (5, 'kiki, 2, 13, 0) INSERT INTO # T VALUES (2, 'girl', 1, 5, 4) INSERT INTO # T VALUES (3, "xiaoxiao", 1, 6, 7) INSERT INTO # T VALUES (6, "bing bing", 3, 10, 11) INSERT INTO # T VALUES (7, 'ice ice, 5, 0, 12) INSERT INTO # T VALUES (8, 'the princess', 4, 0, 0) INSERT INTO # T VALUES (9, 'xiao yu xiao yu', 4, 0, 0) INSERT INTO # T VALUES (10, "SAN SAN, 6, 0, 0) INSERT INTO # T VALUES (11, "shan", 6, 0, 0) INSERT INTO # T VALUES (12, 'slightly' 7, 0, 0) INSERT INTO # T VALUES (13, 'Vivian', 5, 0, 0)
According to the above data, query below
CodePudding user response:
Has the product table product (id int identity, cid int, name nvarchar (50), pubtime datetime) Table with enterprise company (cid int identity, the name nvarchar (50)) There are service table company_service (sid int identity, cid int, service_type id, s_begin date, s_end date)
According to the service level service_type arranged in reverse chronological order of each enterprise products
For example, there are products in a enterprise, a1, a2, a3, level 6, b enterprise, with products b1, b2, level 4, c enterprise, with products c1, c2, c3, c4 and c5
Finally sorted for A1, b1, c1, a2, b2, c2, a3, c3, c4 and c5
CodePudding user response:
Enter a number (8), get the following results:
CodePudding user response:
Please write a stored procedure, realize the input of Chinese characters, print the following image
CodePudding user response:
Please write a stored procedure, the input of a greater than 2 odd number (such as 11), and get the following figure (namely diagonal and equal)
Don't know the complexity of the not enough, arguably the not hard, will not difficult to
The exec sp_MSJZ 11
CodePudding user response:
Yang hui triangle? The rabbit series, Yang multiplication tables, etc.