Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Statement?

Status
Not open for further replies.

eggy168

Programmer
Mar 6, 2002
220
US
Hi, I have a query in Access and I am trying to put it into the View in SQL 2005, is it workable?

Access,
SELECT Field1, Field2, IIF(Field3>Field4,Field3, Field4) As Field5
FROM TableName1
Group BY Field1, Field2, IIF(Field3>Field4), Field3, Field4)

In SQL, it keeps having an error.

SELECT Feild1, Field2, Case When (Field3 > Field4), Field3 Then Field4 As Field5
FROM TableName1
Group BY Field1,Field2

Then I tried this, same error

SELECT Field1, Field2, IF(Field3 > Field4), Field3, Field4 As Field5
FROM TableName1
Group By Field1, Field2

Can anyone help?
Thanks so much.
 
Code:
SELECT Field1, Field2, CASE WHEN (Field3 > Field4) THEN Field3 ELSE Field4 END As Field5
FROM TableName1
Group BY Field1,Field2
 
Code:
SELECT Feild1, Field2, 
       CASE WHEN (Field3 > Field4)
            THEN Field3
            ELSE Field4 END As Field5
FROM TableName1
Group BY Field1,Field2

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Thank You Very Much!! It works Perfect!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top