Results 1 to 14 of 14

Thread: [RESOLVED] - why i got an error here in my query?

  1. #1

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Resolved [RESOLVED] - why i got an error here in my query?

    Pls. do comments here in my query
    VB Code:
    1. rsbrand.Open "SELECT MARGIN, BRAND, SUM(ADAMOUNT) as adamount1 FROM INITIAL_QUOTE_DETAIL GROUP BY BRAND ORDER BY BRAND", conn, adOpenDynamic, adLockOptimistic
    why i got an error?
    Error occured: "You tried to execute a query that does not include the specified expression MARGIN as part of an aggregate function"

    Any help really appreciated... Thanks in advance
    Last edited by noielen; Mar 30th, 2006 at 04:39 AM.
    noister
    <advertising link removed by moderator>

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

    Re: why i got an error here in my query?

    When you perform a aggregrate operation in the select list you need to perform some kind of aggregrate function on all items or include them in a GROUP BY clause.
    VB Code:
    1. SELECT MARGIN, BRAND, SUM(ADAMOUNT) as adamount1 FROM INITIAL_QUOTE_DETAIL GROUP BY BRAND, [b]MARGIN[/b] ORDER BY BRAND
    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
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: why i got an error here in my query?

    when you use group by command you have put all the queried fields in the group by section

    VB Code:
    1. rsbrand.Open "SELECT MARGIN, BRAND, SUM(ADAMOUNT) as adamount1 FROM INITIAL_QUOTE_DETAIL GROUP BY MARGIN, BRAND ORDER BY  BRAND", conn, adOpenDynamic, adLockOptimistic

    and ofcourse the fields with aggregate functions need not to be

    Edit : edited the statement.
    Last edited by ganeshmoorthy; Mar 30th, 2006 at 03:54 AM.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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

    Re: why i got an error here in my query?

    But you forgot to put the MARGIN field in the GROUP BY clause. The ORDER BY clause doesnt matter.
    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
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: why i got an error here in my query?

    Rob : I'm sorry for the copy, paster mistake..edited the post and now it should be correct
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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

    Re: why i got an error here in my query?

    Nothing to be sorry about. Its all good
    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
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: why i got an error here in my query?

    Thanks a lot for correcting mine
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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

    Re: why i got an error here in my query?

    [color=navy]Still because you did get the explaination in your post correct. Just a copy/paste error. [/coor]
    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

  9. #9
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: why i got an error here in my query?

    ok...fine...thanks
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  10. #10

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: why i got an error here in my query?

    Thanks to you all... actually this is my first to use GROUP BY with 2 fields...
    noister
    <advertising link removed by moderator>

  11. #11

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: why i got an error here in my query?

    Thanks, works fine
    noister
    <advertising link removed by moderator>

  12. #12
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: why i got an error here in my query?

    Solution is
    '1f rsbrand.State = 1 Then
    ' rsbrand.Close
    'End If
    'rsbrand.Open "select margin,brand,adamount form initial_quote_detail where sum(adamount)=' adamount1'GROUP BY BRAND ORDER BY BRAND", conn, adOpenDynamic, adLockOptimistic
    'shakti5385@ yahoo.co.In

  13. #13
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: why i got an error here in my query?

    what is this shakthi5385, i couldnt understand what you are trying to post...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  14. #14

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: why i got an error here in my query?

    Thanks shakti53585, but the above posters already helped my prob... and this thread has been resolved by them..

    Thanks to you again...
    noister
    <advertising link removed by moderator>

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