![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi I trying to create a query that will count the invoice and group the results by Month and type
I have this statement: select COUNT(*) As 'Count', DATEPART(YYYY, InvoiceDt) AS 'Year', DATEPART(MM, InvoiceDt) AS 'Month1', SUM(invoiceAmount)AS 'Invoice Amount', InvoiceType AS 'Type', InvoiceStatus AS 'Status' from Invoice where InvoiceStatus = 'C' group by InvoiceType, InvoiceStatus, InvoiceDt order by Month1 and I am getting the following data: Count Year Month Amount Type Status 1 2012 3 10.00 AccountCredit C 1 2012 3 10.00 AccountCredit C 1 2012 3 10.00 AccountCredit C 1 2012 3 25.00 Recharge C 1 2012 4 30.00 AccountCredit C 1 2012 4 0.00 Activation C 1 2012 4 0.00 Activation C 1 2012 5 14.70 AccountCredit C 1 2012 5 14.70 AccountCredit C 1 2012 5 0.50 AccountCredit C 1 2012 5 0.50 AccountCredit C But what I really need is to group by Type and month with the total count and the total Invoice amount, like this: Count Year Month Amount Type Status 3 2012 3 30.00 AccountCredit C 1 2012 3 25.00 Recharge C 1 2012 4 30.00 AccountCredit C 2 2012 4 0.00 Activation C 4 2012 5 30.40 AccountCredit C and after that I need to join with another query that will give me the totals of each type, somethng like this: Null Null Null 90.40 AccountCredit C Null Null Null 25.00 Recharge C Null Null Null 0.00 Activation C Please help me to do this. Thanks |
| Sponsored links |
|
|
|
#2
|
|||
|
|||
|
I already figured it out.
Thanks |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Facebook Group | Major Attitude | Lounge | 185 | 03-18-12 08:49 |
| Win Server 2003 Security/group question... | ifrydr | Software | 1 | 01-09-12 13:37 |
| Mod Group Name. | Spock96 | Lounge | 20 | 10-23-11 00:50 |
| Group Policy | blacknwhite88 | Software | 0 | 10-14-10 01:19 |
| Group Policies | mrudella | Software | 3 | 04-07-04 19:40 |