Sign in to follow this  
Followers 0

SQL Sum statement

12 posts in this topic

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.

0

Share this post


Link to post
Share on other sites

Are you getting an error or invalid results?

Also, try:

SELECT SUM(FIELD) FROM TABLE1,TABLE2 WHERE conditions

without the extra select statement.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites
It was kind of a wild guess :P

That's what I hate about programming!

-:P

0

Share this post


Link to post
Share on other sites
That's what I love about programming!

-NC

That's what I hate about programming!

-:P

That's what I love about forums!

-:cool:

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

All you need is MySQL and the console :P

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

0

Share this post


Link to post
Share on other sites
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 ;)

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0