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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Im missing a bracket!!

Status
Not open for further replies.

newtosql

Programmer
Joined
Apr 7, 2003
Messages
18
Location
US
Can anyone tell me where Im missing a bracket? ')'

if (select COUNT(ms) FROM [table_name] WHERE (CONVERT(int, ms)/1000)/3600) > 3
begin
....

Thanks!
 
Before the greater than:
if (select COUNT(ms) FROM [table_name] WHERE (CONVERT(int, ms)/1000)/3600)) > 3

MakeItSo
 
you have not correct condition in WHERE clause

WHERE (CONVERT(int, ms)/1000)/3600

you have to add something at the end, for example:

WHERE (CONVERT(int, ms)/1000)/3600 = something ) > 3

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Zhavic,

The WHERE is correct except for the missing parenthesis. The = something that you suggest isn't needed and will probably cause an error.

-SQLBill
 
This is why I alway use aligned formting

Code:
IF ( SELECT COUNT(ms) 
       FROM [table_name] 
      WHERE (
             CONVERT(int, ms)/1000
            )/3600
   ) > 3
BEGIN
.
.
.

It is much easier to see your mistake here

Hope I've been helpful,
Wayne Francis

If you want to get the best response to a question, please check out FAQ222-2244 first
 
Hmmmm, SQLBill, so what you are think about this condition:

Code:
WHERE (
         CONVERT(int, ms)/1000
      )/3600

after litle 'makeup':

WHERE CONVERT(int, ms) / 3600000

or more simple

WHERE ms / 3600000

This really not seems to be good, still missing something at the end :-)

The errors that compiler gives you are not always that you have to look for.
If compiler get's you error you are missing some bracket, it may not be the problem that you forgot somewhere one, but may be you have forgot some expression.


Simplest version of problem statement:
Code:
if ( SELECT ... WHERE ms / 3600000 ) > 3
                                  ^  
                                  |
and look there -------------------|

And for this statement, it gives me error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ')'.

It means not missing a bracket, but something around it :-)

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Like Bill wrote:
you have not correct condition in WHERE clause

WHERE (CONVERT(int, ms)/1000)/3600

You cannot say sth like: "Where 3"
You must say "Where [field] = 3"

The CONVERT is just a formatting thing. You must tell Access which value to compare with the convert output.
 
Zhavic,

You need it to be:

if ( SELECT ... WHERE (ms / 3600000 ) > 3)

You were missing two parenthesis. Try it this way:

SELECT ... WHERE (14400000/3600000) > 3

becomes:
SELECT .... WHERE (4) > 3

Which is true (four is greater than 3) and the SELECT will be done.

-SQLBill
 
Yes, you are right Bill, SELECT will be than,
but there is also IF statement around that SELECT, and it still needs some other condition at the end, for example

if ( SELECT COUNT(...) WHERE (4) > 3 ) = 5


Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Zhavic,

Now I see the point you were making. I was looking strictly at the WHERE statement, you were talking about the IF.

Sorry for misunderstanding you.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top