-2

I have a PHP, MySQL project in which reporting section I want to show three functions of the database in the reporting section:

  1. Fetch data from the database table receipts
  2. Sum column r_amount by user
  3. Filter data between two dates

Thanks

Chris J
  • 30,688
  • 6
  • 69
  • 111
  • 3 functionality? Do you mean three database functions - what are they? I can *guess* based on your question, but it's not immiately clear (my guesses for two are: "filter on date range", "sum values" but I don't know what the third function is?) – Chris J Jan 31 '14 at 08:57
  • No, there is only one database and 3 functionality means 1)data show 2) sum of a column. 3)show all above between date in one query – user3256522 Jan 31 '14 at 10:26

3 Answers3

1
SELECT   user, SUM(r_amount)
FROM     receipts
WHERE    date BETWEEN ? AND ?
GROUP BY user
eggyal
  • 122,705
  • 18
  • 212
  • 237
0

Hello Welcome to Stack Overflow

You should search before posting anything, there are many threads/posts regarding this question

select * from reciepts where date BETWEEN '" . $from_date . "' AND  '" . $to_date . "'
order by id desc

select sum(r_amount) from reciepts where date BETWEEN '" . $from_date . "' AND  '" . $to_date . "' order by id desc
ɹɐqʞɐ zoɹǝɟ
  • 4,342
  • 3
  • 22
  • 35
0

1.data between 2 dates

SELECT items,... FROM receipts 
WHERE From_date >= 'date1'
AND To_date <= 'date2'

2.sum between 2 dates

SELECT sum(item)as r_amount FROM receipts 
WHERE From_date >= 'date1'
AND To_date <= 'date2'
Sagar Patni
  • 312
  • 2
  • 11