You are here: Need suggestion of SQL query « PHP SQL « IT news, forums, messages
Need suggestion of SQL query

Posted by Alex on 03/10/07 19:37

Hey everyone,

I'm working on a project that will let the users store their budget,
and in the backbone I have a MySQL database. However, I'm not really
fluent in SQL. I have two questions:

The first is a request for a suggestion of a SQL query. I have a table
that contains all user entries in the following format:

id member_id date amount
1 1 070210 2.3
2 1 070210 4.3
3 2 070211 5.8
4 2 070212 1.6
5 1 070213 3.2

In order to sum up the total amount for a specific member, I use the
the following query:

SELECT SUM(amount) as amount FROM budget WHERE member_id=1

Now how do I solve this if I'd like to limit the SUM to count the
amount in entries between specific id's? The reason for this is that I
have a table that shows every member's expenses. The number of rows
can be set by the member and is taken care of with a LIMIT command in
that function, but the same method isn't working in this query. Any
ideas of how to solve this?

Then I have a "follow-up" question. When I use the SUM function on the
amounts above, I end up with a number with loads of decimals when I'd
only like one. Right now I'm solving this with a ROUND command. The
types of the column is FLOAT. Any ideas?

Thanks a lot in advance.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация