Results 1 to 23 of 23

Thread: sum aggregate function ???

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Question sum aggregate function ???

    This access query is returning the sum amount for days 1-31 in January... so I see 31 rows of Data... they all have the same account number... I want to see 1 row of data summed up for all of January... what am I forgetting

    Thanks,

    John


    Code:
    SELECT DISTINCT [Budget].[Hotel],[Budget].[DrptDate],  [Budget].[Account], [Budget].[Description], [Budget].[Amount], Sum([Budget].[Amount]) AS SumOfAmount
    FROM Budget
    WHERE ((([Budget].[Account])="10-41220")) And month([budget].[drptdate])=1 and budget.hotel = "CQSC"
    GROUP BY ([Budget].[DrptDate]), [Budget].[Hotel], [Budget].[Account], [Budget].[Description], [Budget].[Amount];

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    This would be better in the DB Forum, but I can answer it.
    I'm not sure about the Distinct clause being
    needed since your summing and grouping. Also, your grouping on each day in the month of Janurary so you can not get
    one row for a result unless you used a alias field and set the value to "Janurary". See if this helps get you closer.

    VB Code:
    1. SELECT
    2.  [Budget].[Hotel],
    3.  "Janurary" As DrptMonth,
    4.  [Budget].[Account],
    5.  [Budget].[Description],
    6.  [Budget].[Amount],
    7.  Sum([Budget].[Amount]) AS SumOfAmount
    8. FROM
    9.  Budget
    10. WHERE
    11.  (
    12.   (
    13.    ([Budget].[Account])="10-41220")
    14.   )
    15.   And
    16.  Month([budget].[drptdate])=1
    17.   And
    18.  budget.hotel = "CQSC"
    19. GROUP BY
    20.  DrptMonth,
    21.  [Budget].[Hotel],
    22.  [Budget].[Account],
    23.  [Budget].[Description],
    24.  [Budget].[Amount];
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    hey,

    I did what you said and it brought my query back with 4 rows... hmmm...

    oh and where is the other forum you suggested...

    Thanks,

    John

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    The Database Development Forum

    What were the repeating results?

    Did you try it with and without the Distinct keyword?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    not sure... when I replaced the date column with your suggestion I get the results below... if I put my date column back in with your suggestion I get all 31 days back again...

    I wonder if there were spaces in the hotel column or account column would be the reason???

    Code:
    Hotel	DrptMonth	Account	Description	Amount	SumOfAmount
    CQSC	Janurary	10-41220	Business Travel Club	-820	-820
    CQSC	Janurary	10-41220	Business Travel Club	-492	-492
    CQSC	Janurary	10-41220	Business Travel Club	-410	-820
    CQSC	Janurary	10-41220	Business Travel Club	-246	-246
    CQSC	Janurary	10-41220	Business Travel Club	-164	-1312
    CQSC	Janurary	10-41220	Business Travel Club	-82	-1476

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    Its the Amount field. You can not group and sum and still have a detail of the group. Its like grouping
    and then ungrouping. Take out the Amount field and see how it get afected.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    "SOLVED!!!!"Re: sum aggregate function ???

    you are the man!!!!!!!!

    THANK YOU....

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    oops, now how do I get it to do for all 12 months and all hotels???

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    Thanks We need to change it so it will group and sum for each month. Hold on and I wil give it a shot.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    Quick Q. Is this for Access or SQL Server?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    Access

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    How do you want the dates displayed as - "Janurary" or 01/2005?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    See how this is. I didnt have a db to test against and I assummed that it would be
    for all hotels and all accounts for 2005 and in a month date format.

    VB Code:
    1. SELECT
    2.  [Budget].[Hotel],
    3.  IIF(Month([budget].[drptdate])=1,
    4.   "Janurary",
    5.    IIF(Month([budget].[drptdate])=2,
    6.     "Febraury",
    7.      IIF(Month([budget].[drptdate])=3,
    8.       "March",
    9.        IIF(Month([budget].[drptdate])=4,
    10.         "April",
    11.          IIF(Month([budget].[drptdate])=5,
    12.           "May",
    13.            IIF(Month([budget].[drptdate])=6,
    14.             "June",
    15.              IIF(Month([budget].[drptdate])=7,
    16.               "July",
    17.                IIF(Month([budget].[drptdate])=8,
    18.                 "August",
    19.                  IIF(Month([budget].[drptdate])=9,
    20.                   "September",
    21.                    IIF(Month([budget].[drptdate])=10,
    22.                     "October",
    23.                      IIF(Month([budget].[drptdate])=11,
    24.                       "November","December"))))))))))) As DrptMonth,
    25.  [Budget].[Account],
    26.  [Budget].[Description],
    27.  Sum([Budget].[Amount]) AS SumOfAmount
    28. FROM
    29.  Budget
    30. WHERE
    31.  Year([budget].[drptdate])=2005
    32. GROUP BY
    33.  DrptMonth,
    34.  [Budget].[Hotel],
    35.  [Budget].[Account],
    36.  [Budget].[Description];
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    sweet!!! Thanks a bunch...

    John

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    No prob. Did it work correctly?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: sum aggregate function ???

    Sorry to butt in wouldn't
    Code:
    SELECT 
     [Budget].[Hotel],
     Format([budget].[drptdate],"mmmm") As DrptMonth,
     [Budget].[Account],
    ...
    Be easier?
    Or does that mess up the query?
    Last edited by Ecniv; Feb 11th, 2005 at 10:14 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    Yes, much easier. I always seem to do things the hard way.

    VB Code:
    1. Format([budget].[drptdate],"mmmm") As DrptMonth,
    Should not mess up the results since its basicly doing the same thing but simplier.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    No it didn't work... and now of course I need the same thing for a real world project today.

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    Which query did you try or was it both? Post what your using?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    Lets try this approach...
    This code works correctly... however, adding the Date to the select adds thousands of rows... i need to have the a column that represents the date
    of 1/31/05, and 2/31/05 and so on... a psudocolumn if you will... so that I can import properly... to another table


    Code:
    SELECT hotel, account, Description, sum(amount)
    FROM Budget
    where account = '199-41200' and month(drptdate) = 1 and year(drptdate) = '2005'
    group by hotel, account, Description;

    Code:
    hotel	account	Description	Expr1003
    ABVA	199-41200	Rooms Rented - Rack/Corp Transient	445
    ACMI	199-41200	Rooms Rented - Rack/Corp Transient	1146
    AFMI	199-41200	Rooms Rented - Rack/Corp Transient	649
    AHGA	199-41200	Rooms Rented - Rack/Corp Transient	223
    BNNC	199-41200	Rooms Rented - Rack/Corp Transient	543
    BRGA	199-41200	Rooms Rented - Rack/Corp Transient	53
    CANC	199-41200	Rooms Rented - Rack/Corp Transient	601
    CCVA	199-41200	Rooms Rented - Rack/Corp Transient	75
    CEFL	199-41200	Rooms Rented - Rack/Corp Transient	166
    CGNY	199-41200	Rooms Rented - Rack/Corp Transient	808
    CHNC	199-41200	Rooms Rented - Rack/Corp Transient	273
    CMNC	199-41200	Rooms Rented - Rack/Corp Transient	416
    CNSC	199-41200	Rooms Rented - Rack/Corp Transient	492
    CQSC	199-41200	Rooms Rented - Rack/Corp Transient	540
    DCNC	199-41200	Rooms Rented - Rack/Corp Transient	828
    DHNC	199-41200	Rooms Rented - Rack/Corp Transient	218
    DUNC	199-41200	Rooms Rented - Rack/Corp Transient	673
    EGIL	199-41200	Rooms Rented - Rack/Corp Transient	1004
    FCNC	199-41200	Rooms Rented - Rack/Corp Transient	347
    GVSC	199-41200	Rooms Rented - Rack/Corp Transient	272
    GWGA	199-41200	Rooms Rented - Rack/Corp Transient	641
    HCNC	199-41200	Rooms Rented - Rack/Corp Transient	92
    HHSC	199-41200	Rooms Rented - Rack/Corp Transient	262
    HMTX	199-41200	Rooms Rented - Rack/Corp Transient	1161
    HPAZ	199-41200	Rooms Rented - Rack/Corp Transient	366
    JVNC	199-41200	Rooms Rented - Rack/Corp Transient	685
    LHFL	199-41200	Rooms Rented - Rack/Corp Transient	434
    OCFL	199-41200	Rooms Rented - Rack/Corp Transient	217
    PHGA	199-41200	Rooms Rented - Rack/Corp Transient	241
    PVFL	199-41200	Rooms Rented - Rack/Corp Transient	244
    RGNC	199-41200	Rooms Rented - Rack/Corp Transient	1086
    RHNC	199-41200	Rooms Rented - Rack/Corp Transient	1199
    RPAZ	199-41200	Rooms Rented - Rack/Corp Transient	700
    SCNJ	199-41200	Rooms Rented - Rack/Corp Transient	804
    SHMA	199-41200	Rooms Rented - Rack/Corp Transient	147
    SLGA	199-41200	Rooms Rented - Rack/Corp Transient	428
    THNJ	199-41200	Rooms Rented - Rack/Corp Transient	131
    WCNC	199-41200	Rooms Rented - Rack/Corp Transient	278
    WGGA	199-41200	Rooms Rented - Rack/Corp Transient	214
    WMNC	199-41200	Rooms Rented - Rack/Corp Transient	548
    WPNY	199-41200	Rooms Rented - Rack/Corp Transient	784

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    I thought thats what I had on my big query I posted? The psuedocolumn was DrptMonth.
    You need to Group By on the psuedocolumn also in order to eliminate the
    mass record returns.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: sum aggregate function ???

    I did that and I get this error


    "you tried to execute a query that does not include the specified expression..."

    I am doing something wrong....


    Code:
    SELECT IIF(Month([budget].[drptdate])=1,
      "Janurary",
       IIF(Month([budget].[drptdate])=2,
        "Febraury",
         IIF(Month([budget].[drptdate])=3,
          "March",
           IIF(Month([budget].[drptdate])=4,
            "April",
             IIF(Month([budget].[drptdate])=5,
              "May",
               IIF(Month([budget].[drptdate])=6,
                "June",
                 IIF(Month([budget].[drptdate])=7,
                  "July",
                   IIF(Month([budget].[drptdate])=8,
                    "August",
                     IIF(Month([budget].[drptdate])=9,
                      "September",
                       IIF(Month([budget].[drptdate])=10,
                        "October",
                         IIF(Month([budget].[drptdate])=11,
                          "November","December"))))))))))) As DrptMonth,hotel, account, Description, sum(amount), '01/31/2005' AS [LastDayOfMonth]
    FROM Budget
    where  year(drptdate) = '2005' and account IN('199-41200', '199-41215', '199-41225', '19941220', '199-42130', '199-41250', '199-41255', '199-41340', '199-41290', '199-41291', '199-41240', '199-41320')
    group by DrptMonth, hotel, account, Description;

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sum aggregate function ???

    What is the last part of the message? It should tell you the name of the offending field.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width