Jump to content


Photo

Clean upTable


Best Answer Barand, 19 May 2013 - 04:37 PM

try

SELECT TYPE, SUM(Amount) as total 
FROM DEBITS 
WHERE TYPE='Cell Phone' 
AND DATE(Date) BETWEEN '2012-05-20' AND '2013-05-21'
GROUP BY TYPE
Go to the full post


  • Please log in to reply
6 replies to this topic

#1 rusking

rusking

    Advanced Member

  • Members
  • PipPipPip
  • 52 posts

Posted 19 May 2013 - 04:08 PM

SELECT TYPE,date , (Amount) FROM DEBITS where TYPE='Cell Phone' HAVING Date BETWEEN '1999-05-20 00:00:00' AND '2013-05-21 00:00:00'

Gives me :

Attached File  1.png   28.77KB   5 downloads

 

Im trying to add all the 'Vaule' displayed. IF i SUM like this

SELECT TYPE,date , SUM(Amount) FROM DEBITS where TYPE='Cell Phone' HAVING Date BETWEEN '1999-05-20 00:00:00' AND '2013-05-21 00:00:00'

 I get:

Attached File  2.png   24.55KB   11 downloads

 

 

 

 

This seems correct but if i chage the dates and sum:

SELECT TYPE,date , SUM(Amount) FROM DEBITS where TYPE='Cell Phone' HAVING Date BETWEEN '2012-05-20 00:00:00' AND '2013-05-21 00:00:00'

I return :

Attached File  2.png   24.55KB   11 downloads

 

 

I am new to MySQLi and have been learning it the past 30 hours. Ultimately if i could add only the 'Vaule' of the proucted array i should be ok but i keep breaking it


Edited by rusking, 19 May 2013 - 04:17 PM.


#2 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 14,425 posts
  • LocationCheshire, UK

Posted 19 May 2013 - 04:16 PM

At least make some attempt to make the outputs readable


moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#3 rusking

rusking

    Advanced Member

  • Members
  • PipPipPip
  • 52 posts

Posted 19 May 2013 - 04:18 PM

fixed the outputs so they should be easier to read now


Edited by rusking, 19 May 2013 - 04:18 PM.


#4 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 14,425 posts
  • LocationCheshire, UK

Posted 19 May 2013 - 04:26 PM

What output are you trying to get? You haven't said what your problem is, all you've done is tell us what you have tried.


moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#5 rusking

rusking

    Advanced Member

  • Members
  • PipPipPip
  • 52 posts

Posted 19 May 2013 - 04:30 PM

It currently adds the amounts column if i use SUM. Im wanting it to when it narow the date, only add the amounts ('vaule') shown. The third returned image shows its still addin all teh amounts instead of teh selected dates. The first returned image shows every entry for reference


Edited by rusking, 19 May 2013 - 04:32 PM.


#6 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 14,425 posts
  • LocationCheshire, UK

Posted 19 May 2013 - 04:37 PM   Best Answer

try

SELECT TYPE, SUM(Amount) as total 
FROM DEBITS 
WHERE TYPE='Cell Phone' 
AND DATE(Date) BETWEEN '2012-05-20' AND '2013-05-21'
GROUP BY TYPE

moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#7 rusking

rusking

    Advanced Member

  • Members
  • PipPipPip
  • 52 posts

Posted 19 May 2013 - 04:41 PM

i think that solved it, thankyou very much


Edited by rusking, 19 May 2013 - 04:41 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com