|
-
Mar 30th, 2006, 03:20 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] - why i got an error here in my query?
Pls. do comments here in my query
VB Code:
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>
-
Mar 30th, 2006, 03:50 AM
#2
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:
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 30th, 2006, 03:51 AM
#3
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:
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.
-
Mar 30th, 2006, 03:52 AM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 30th, 2006, 03:55 AM
#5
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.
-
Mar 30th, 2006, 03:59 AM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 30th, 2006, 04:00 AM
#7
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.
-
Mar 30th, 2006, 04:02 AM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 30th, 2006, 04:06 AM
#9
Re: why i got an error here in my query?
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.
-
Mar 30th, 2006, 04:09 AM
#10
Thread Starter
Fanatic Member
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>
-
Mar 30th, 2006, 04:12 AM
#11
Thread Starter
Fanatic Member
Re: why i got an error here in my query?
noister
<advertising link removed by moderator>
-
Mar 30th, 2006, 04:29 AM
#12
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
-
Mar 30th, 2006, 04:36 AM
#13
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.
-
Mar 30th, 2006, 04:39 AM
#14
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|