Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

bill_no  datetime                   amount
1;      "2014-12-23 17:36:07";      382.02
1;      "2014-12-23 09:08:37";      1452.38
2;      "2014-12-23 18:18:26";      472.99
2;      "2014-12-23 09:56:44";      380.95
3;      "2014-12-23 10:00:07";      666.67
3;      "2014-12-23 18:42:43";      159.18
4;      "2014-12-23 10:12:54";      200.00
4;      "2014-12-23 18:43:25";      77.31
5;      "2014-12-23 10:15:21";      7857.14
5;      "2014-12-23 18:45:27";      409.31
6;      "2014-12-23 20:50:56";      318.36
6;      "2014-12-23 10:16:00";      761.90
7;      "2014-12-23 20:59:59";      109.16
7;      "2014-12-23 10:16:58";      1571.43


Here how to get the total of all the bill_no's depending on datetime.

now if i am trying sum(amount) it's taking only single values from the duplicate rows.

Please tell me how to do this..
Posted
Comments
DamithSL 2-Feb-15 5:32am    
what the sql statement you tried?
Black_Rose 2-Feb-15 5:48am    
select 'ASales Amt' as tran_type, sum(amount) as net_total from tbl_transaction_master Where to_char(bill_date,'yyyy-MM-dd')>='2014-12-23' and to_char(bill_date,'yyyy-MM-dd')<='2014-12-23'

1 solution

You should try this

SQL
SELECT bill_no, sum(amount) as net_total FROM tbl_transaction_master
WHERE bill_date >='2014-12-23 00:00:00' AND bill_date <='2014-12-23 23:59:59'
GROUP BY bill_no
ORDER BY bill_no


it will work for you :) .

Thank you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900