Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010
    Posts
    33

    Unanswered: Get the number of checks and total by week

    I need to be able to get the number of checks issued per week and the total dollar amount (Sun-Sat).


    Below is a sample of the raw data:
    HTML Code:
     TransactionDate               Check#     Description         CheckAmount
    2011-04-23 00:00:00.000	2658	Release Check	66.5500
    2011-04-23 00:00:00.000	2659	Release Check	2.5900
    2011-04-20 00:00:00.000	2660	Release Check	0.4400
    2011-04-17 00:00:00.000	2661	Release Check	0.4200
    2011-03-14 00:00:00.000	2655	Release Check	83.1000
    2011-03-02 00:00:00.000	2657	Release Check	1.0000
    2011-03-01 00:00:00.000	2662	Release Check	23.1600

    HTML Code:
    Expected Output:
    
    Week                             Number Of Checks         Total Dollar Amount
    17 Apr -23 April 2011                 4                              $70
    13 Mar - 19 Mar 2011                1                              $83.10
    27 Feb - 5 Mar 2011                  2                              $24.16
    I would greatly appreciate any recommendations to solve this problem. I am just learning SQL. My data is on a SQL 2008 box.
    Last edited by ptyo; 04-26-11 at 10:41. Reason: Put code tags around expected output

  2. #2
    Join Date
    Jun 2010
    Posts
    33

    Solved.. thanks google... gotta love it..

    Hope this may help someone else:

    HTML Code:
    Select DATEPART(yy,transactiondate), DATEPART(wk,transactiondate), SUM(CheckAmount)
    From souser.ReleasedChecks
    group by 
    DATEPART(yy,transactiondate), DATEPART(wk,transactiondate)
    order by DATEPART(yy,transactiondate) desc, datepart(wk,transactiondate)desc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •