AndrewMozley
Programmer
I have a table of sales orders, XSORD.dbf. Two of the fields are the customer’s account code, 'Account’ and our sales order reference, ‘Sales_Ref’. (I can also get the customer’s name from another table XCUST using the account code to look that up).
Would like to extract from this table a cursor which groups the orders with the same customer and sales reference, and provides for each a count of how many times that same combination occurs in the table XSORD.
So the result should be something like :
Customer________ Sales Ref Count
A123 Auto supplies SR0357 1
A123 Auto Supplies SR0462 2
B506 Britsh Zinc___SR9356 1
. . .
So far I have attempted code like :
SELECT ACCOUNT, Sales_Ref, Account + Sales_Ref AS Comp1 FROM XSORD GROUP BY Comp1 INTO cursor T
But this comes up with a ‘Group By' error. I also realise that I might well need a COUNT() clause as part of the SELECT statement.
As you can see I have very limited experience of SQL SELECT - Can anyone recommend a beginner’s guide?
Would like to extract from this table a cursor which groups the orders with the same customer and sales reference, and provides for each a count of how many times that same combination occurs in the table XSORD.
So the result should be something like :
Customer________ Sales Ref Count
A123 Auto supplies SR0357 1
A123 Auto Supplies SR0462 2
B506 Britsh Zinc___SR9356 1
. . .
So far I have attempted code like :
SELECT ACCOUNT, Sales_Ref, Account + Sales_Ref AS Comp1 FROM XSORD GROUP BY Comp1 INTO cursor T
But this comes up with a ‘Group By' error. I also realise that I might well need a COUNT() clause as part of the SELECT statement.
As you can see I have very limited experience of SQL SELECT - Can anyone recommend a beginner’s guide?