LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-26-2003, 03:32 PM   #1
zimba
LQ Newbie
 
Registered: Mar 2003
Location: Geneva, CH
Distribution: MDK9.0,SME,IPCop,OpenBSD
Posts: 10

Rep: Reputation: 0
MySQL SUM Query


Hia, first hello to everybody I'm new to the forum :-)

I'm totally lost with a complicated sql query, can smbdy help me ?

Look :
I got a table with reparations incommings:

Fields : RepID, RepDateTime, RepTotalCost

Now I'd like to SUM() all incomming reparations for each day in the table.
Is it possible to do it in one query ?

Hope :-P

zimba
 
Old 03-27-2003, 08:37 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,415

Rep: Reputation: 99
select SUM(RepTotalCost) from db where RepDateTime<somevalue and RepDateTime>othervalue;

u may use BETWEEN function in the where clause too

if u want to select sums of a lot of days at once i guess u need to make a temporary table for each day or switch to a db that supports subselects

Last edited by j-ray; 03-27-2003 at 09:04 AM.
 
Old 03-27-2003, 03:10 PM   #3
zimba
LQ Newbie
 
Registered: Mar 2003
Location: Geneva, CH
Distribution: MDK9.0,SME,IPCop,OpenBSD
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks a lot j-ray,

I just read today that MySQL 4.1 supports subselects so I don't have to change my DB, just upgrade :-P

cf. MySQL Press Release 21 Jan 2003

thanx,
zimba
 
Old 03-28-2003, 09:55 AM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,415

Rep: Reputation: 99
nice to hear that. it's a great improvement that was announced for long. gonna get me that too. ;-)
cheers, jens
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mySQL query help ezra143 Programming 3 04-25-2005 03:17 PM
Need mysql query help DropHit Linux - Software 7 04-01-2005 11:32 AM
MySQL Query Help Gerardoj Programming 1 06-10-2004 09:54 PM
Mysql Error: Lost Connection to Mysql during query ramnath Programming 5 11-18-2003 12:27 PM
mysql query ????? shaahul Linux - Newbie 1 09-06-2003 03:28 AM


All times are GMT -5. The time now is 05:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration