Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Msg 156, Level 15, State 1, Line 12
Incorrect syntax near the keyword 'SELECT'.


Please assist to rectify


MS-SQL SERVER -2008



Note No Surround for T-SQL


SQL
DECLARE @Request AS TABLE (Req_ID VARCHAR (20),
R1 INT, R2 INT, R3 INT, R4 INT, R5 INT)

INSERT INTO @Request VALUES('R12673',2, 5, 3, 7, 10)
INSERT INTO @Request VALUES('R34721',3, 5, 2, 1, 8)
INSERT INTO @Request VALUES('R27835',1, 3, 8, 5, 6



SELECT Req_ID,
(SELECT AVG(c)
FROM (VALUES(R1),
(R2),
(R3),
(R4),
(R5)) T (c)) AS [Average]
FROM @Request


What I have tried:

Program Codes. Needs help to correct the program segment
Posted
Updated 3-Nov-17 5:56am
v2

You're missing the close bracket on line 5
 
Share this answer
 
Missing close bracket:
SQL
INSERT INTO @Request VALUES('R27835',1, 3, 8, 5, 6
                                                  ^
SELECT Req_ID,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900