SQL Sum statement

Hi guys,

I've just got into this problem which is driving me nuts. I've got a query to return data from 2 tables in my database (MS SQL). Then I'd like to perform a SUM on one of the field returned by the query but I can't find a way to do so.

I've tried this

SELECT SUM(FIELD) FROM (SELECT * FROM TABLE1, TABLE2 WHERE conditions)

but apparently this is not the right way to do it...

Anyone got any idea?

Thanks in advance.

#458514

Are you getting an error or invalid results?

Also, try:

SELECT SUM(FIELD) FROM TABLE1,TABLE2 WHERE conditions

without the extra select statement.

#458536

excellent mate it worked like a charm :D thanks a lot

#458540

Hehe, I'm just starting to learn SQL for my upcoming job. It was kind of a wild guess :P

#458544

It was kind of a wild guess :P

That's what I love about programming!

-NC

#458546

It was kind of a wild guess :P

That's what I hate about programming!

-:P

#458629

That's what I love about programming!

-NC

That's what I hate about programming!

-:P

That's what I love about forums!

-:cool:

#458674

is there a good SQL app for mac?

#458677

What do you mean by SQL app? Mac OS X comes with MySQL server (if I remember correctly.)

#458683

All you need is MySQL and the console :P

Does anybody know a front end for OSX to execute queries, see my DB, etc?

#459205

Does anybody know a front end for OSX to execute queries, see my DB, etc?
All you need is MySQL and the console :P

You answered your own question there ;)

#459220

Can't you install phpMyAdmin? I'm sure someone's done it on OS X...

Check here and look into using MAMP, I suppose.

-NC

#459787