Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-02-2013, 12:16 PM   PM User | #1
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
sum(number)

Code:
select sum(111) = 111
now try:

Code:
select sum(111) from xtable
select sum(111) from ytable
any you get some looks like randome numbers.

Any explanation ?
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search

Last edited by BubikolRamios; 03-02-2013 at 05:58 PM..
BubikolRamios is offline   Reply With Quote
Old 03-05-2013, 09:54 PM   PM User | #2
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 576
Thanks: 15
Thanked 64 Times in 64 Posts
Arcticwarrio is on a distinguished road
what is xtable ?
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 03-05-2013, 10:41 PM   PM User | #3
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
it is any table.
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Old 03-05-2013, 11:07 PM   PM User | #4
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 576
Thanks: 15
Thanked 64 Times in 64 Posts
Arcticwarrio is on a distinguished road
its the number of entrys 3 times eg if you have 51 rows it will output 515151
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 03-05-2013, 11:10 PM   PM User | #5
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 576
Thanks: 15
Thanked 64 Times in 64 Posts
Arcticwarrio is on a distinguished road
or not, 4 rows = 444

31 rows = 3441

so its 111 * rows
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Arcticwarrio is offline   Reply With Quote
Old 03-05-2013, 11:32 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Correct. 55 rows would be 5661.

It's easy to see this, Bubikol, if you do
Code:
SELECT COUNT(*), SUM(111) FROM xtable
What you are telling SQL (any SQL, not just MySQL) to do is to add 111 to the sum for each row in the table.

Think about it: If you do
Code:
SELECT SUM(someField) FROM xtable
all that tells SQL to do is to add the value of field someField to the sum for each row in the table. So when you use a constant, instead, it is the constant that gets added for each row.

Nothing "random" about it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:03 AM.


Advertisement
Log in to turn off these ads.