on 2022 Sep 21 3:02 PM
Hello to all of you,
I admit I'm a rookie but I'm trying to learn easy queries on B1.
In this case I need a very simple query that has to list the customers that don't purchase from us since date xx (last purchase date).
In my head was easy, I thought about OINV table and WHERE conditions "from date" - "to date" but the result is not their last purchase and I guess I need to use MAX(T0."DocDate") but I don't know how.
Can someone suggest me the proper syntax for this query, please?
Fields needed are:
Tx."DocNum"
Tx."DocDate"
Tx."CardName"
Thank you all in advance for your help!
Request clarification before answering.
Hi,
if you want Customers you need to connect your OINV table with the OCRD table.
Maybe something like:
select a2.DocNum, a2.DocDate, a2.CardName
from OCRD as a1 inner join OINV as a2
ON a1.CardCode = a2.CardCode
where a1.CardCode IN
(
Select distinct CardCode
from OINV
where DocDate > DATEADD(year, -1, getdate())
)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Kai,
customers are already into OINV table and they are correctly recalled in other queries so I don't see the need to add the OCRD table.
I just need to know how to use the MAX(docdate) instruction in the following query draft:
select T0."DocNum", T0."DocDate", T0."CardName"
from OINV T0
where ______
| User | Count |
|---|---|
| 29 | |
| 14 | |
| 14 | |
| 6 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.