|
-
Jan 21st, 2010, 03:19 AM
#1
Thread Starter
New Member
Modification Needed
Hello Everybody
I use these code but this returns following error message
Incorrect syntax near the keyword 'group'.
Code:
str = "Select c,acccode,acc_name,title,Count(vou_no)As vou_no,vou_no As balance, sum(qty*weight) As weight,Sum(qty)As qty from gpass order By acccode group By acccode where Date between '" & Me.first_date.Text & "' and '" & Me.last_date.Text & "'"
dt = GetTable(str)
What is wrong, please modify
-
Jan 21st, 2010, 03:34 AM
#2
Re: Modification Needed
GROUP BY should come before ORDER BY
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 21st, 2010, 03:39 AM
#3
Re: Modification Needed
In SQL statements, the WHERE condition comes before the GROUP BY condition
-
Jan 21st, 2010, 03:58 AM
#4
Thread Starter
New Member
Re: Modification Needed
Now I have wrote codes as
Code:
str = "Select c,acccode,tittle,Count(vou_no)As vou_no,vou_no As balance,sum(qty*weight) As weight,Sum(qty)As qty from gpass where Date between '" & Me.first_date.Text & "' and '" & Me.last_date.Text & "' group By acccode order By acccode"
dt = GetTable(str)
but it shows this error message
Code:
Column 'gpass.c' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
The datatype of column c is char(1)
Please help
-
Jan 21st, 2010, 05:23 AM
#5
Re: Modification Needed
you should add it to the group by (and all the other columns)
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
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
|