Sarathchandra
Starting Member
2 Posts |
Posted - 2015-03-28 : 08:01:02
|
Hi, I am new to SQl I have written a code which is as follows but gives an error Msg 102, Level 15, State 1, Line 6Incorrect syntax near 'SALARY'.Please find the code belowCreate Table Person(ID INT, NAME NVARCHAR(255),SALARY INT, JDATE DATETIME,CITY NVARCHAR(255),REGION CHAR(255))insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(1,'MEGAN',25000, '02/01/96','UTAH','W') insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(2,'BRUCE',35000, '02/05/96','NEWYORK','E')insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(3,'KAI',27000, '02/06/97','CHICAGO','S') insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(4,'TYSON',28000, '02/01/96','TEXAS','W') insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(5,'BROOKLYN',29000, '02/07/94','BROOKLYN','W') insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(6,'RAY',30000, '02/01/98','PARIS','W') insert into Person(ID,NAME,SALARY,JDATE,CITY,REGION)VALUES(7,'MAX',31000, '22/1/96','LONDON','W') SELECT * FROM PersonSELECT IDCASE WHEN SALARY=30000 THEN 6WHEN SALARY=35000 THEN 2ELSENO SALARY PRESENTENDgoPlease help me with the correct syntaxSarath chandraSarath chandra |
|