Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Sales 2

Status
Not open for further replies.

johnny45

Technical User
Nov 8, 2006
136
CA
I need to query the accpac sales and sales details tables.

We are on the latest accpac windows with pervasive 9

I need to build an sql query within a date range grouping sales by cust and item.

The data I saw stored in the pervasive table is formated like this: 20071230

How would I build the sql with a date range ?
 
Select * from table where transdate >= 20070101 and transdate <=20071231
 
Thank You !
I've never worked dates as strings before.... :)

I will give this a try Monday...

Code:
sSql = "SELECT *" & vbNewLine
sSql = sSql & "FROM table" & vbNewLine
sSql = sSql & "WHERE transdate >=' " & Format(start_date, "yyyymmdd") & "' and transdate <='" & Format(end_date, "yyyymmdd") & "'"
 
So I have this so far..but I cant seem to get the grouping ...
Code:
SELECT OEORDH.CUSTOMER, OEORDH.ORDNUMBER, OEORDH.SHIPTO, OEORDH.BILNAME, OEORDH.SHPNAME, OEORDH.ORDDATE, OEORDD1.ITEM, OEORDD1.DESC, OEORDD1.UNITPRICE
FROM OEORDH INNER JOIN OEORDD1 ON OEORDH.ORDUNIQ = OEORDD1.ORDUNIQ
WHERE OEORDH.ORDDATE  Between 20081001 And 20081031
GROUP BY OEORDD1.ITEM
ORDER BY OEORDH.CUSTOMER, OEORDH.ORDDATE, OEORDD1.ITEM, Sum(OEORDD1.QTYORDERED), OEORDD1.ITEM;
 
I cant seenm to get the GROUPING to work...

I want to sort by customer and have the sql total the units by ITEM
 
like this :
Code:
SELECT OEORDH.CUSTOMER, OEORDH.ORDNUMBER, OEORDH.SHIPTO, OEORDH.BILNAME, OEORDH.SHPNAME, OEORDH.ORDDATE, OEORDD1.ITEM, OEORDD1.DESC, OEORDD1.UNITPRICE
FROM OEORDH INNER JOIN OEORDD1 ON OEORDH.ORDUNIQ = OEORDD1.ORDUNIQ
WHERE OEORDH.ORDDATE  Between 20081001 And 20081031
GROUP BY OEORDH.CUSTOMER,OEORDD1.QTYORDERED
ORDER BY OEORDH.CUSTOMER, OEORDH.ORDDATE, OEORDD1.ITEM, Sum(OEORDD1.QTYORDERED), OEORDD1.ITEM;
 
Are you looking for sales or for orders, because orders =! sales.
If you strictly want sales information then look at OESHDT or OESHHD.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top