Query for Inactive customer becomes active
Looking for query that will show me all customers that have started to purchase from us.
ie. who have not made a purchase for the past six months and then started up again.
Any help is appreciated.
Try this one:
SELECT T0.CardCode, T0.CardName, (Select Max(DocDate) From DBO.ODLN Where CardCode = T0.CardCode AND DateDiff(dd, docdate, getdate()) < 183
Group By cardcode Having Count(DocENtry) = 1) AS 'DocDate'
From DBO.ODLN T0
Where DateDiff(dd, t0.docdate, getdate()) < 183 AND DateDiff(DD,(Select Max(DocDate) From DBO.ODLN Where CardCode = T0.CardCode AND DateDiff(dd, docdate, getdate()) < 183 Group By cardcode Having Count(DocENtry) = 1), GetDate()) < 31
I have assumed only active within one month should be showed. You could select any days you like by changing the last number.
Thanks
Gordon
Similar Messages
-
Error while creating a query for my custom infotype
Hi,
I have created a custom infotype with fields currency amount and currency field .
While I am creating a query for it its giving an error
Message no. AQ_AD_HOC221 Error when generating the report(see long text )
I tried to execute the standard program RPUMS40CCI but still I am facing same error .
I have also maintained table T777i for my infotype but still problem exists.
Please help.
PHi
Check in PM01 -
MDX Query for Average customer first sale amount for each year
Hello,
I new to MDX, and I am looking to build a query that would get all the first sale amount for the customes and average that. The intent is to use find an average each year. I am looking to use this against the adventure works database.
I am not sure exatcly how to start this . Any help is much appreciated.
JHi,
I'll do it in several stages.
let's first define an ordered set of date/sale to one customer over all periods:
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customter].&[15561]
) ON 1
FROM [Adventure Works];
we retain the first line of the result set with item(0):
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].&[15561]
).Item(0) ON 1
FROM [Adventure Works];
next, for each year we define a measure that will retain the first sale for each customer
(I limit the customer set to the first 2000)
WITH
MEMBER [Measures].[Mymeasure 2006] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[Mymeasure 2007] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[Mymeasure 2006]
,[Measures].[Mymeasure 2007]
} ON 0
,NON EMPTY
Head
[Customer].[Customer].[Customer]
,2000
) ON 1
FROM [Adventure Works];
We then take the average for each year:
WITH
MEMBER [Measures].[AVG cust first sale 2006] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[AVG cust first sale 2007] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[AVG cust first sale 2006]
,[Measures].[AVG cust first sale 2007]
} ON 0
FROM [Adventure Works];
Philip, -
Creating an SQL Query for Project Custom Fields Values
Hello:
I'm currently trying to create an SQL Query to show all of the server's Project Custom Fields Values, along with the modification date.
So far, I've managed to display correctly all of the data for all of the Projects' text value Custom Fields (those not based on a LookUp Table) with this query:
SELECT
MSP_PROJECTS.PROJ_NAME,
MSP_CUSTOM_FIELDS.MD_PROP_NAME,
MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE,
MSP_PROJ_CUSTOM_FIELD_VALUES.TEXT_VALUE,
MSP_PROJ_CUSTOM_FIELD_VALUES.MOD_DATE
FROM
MSP_PROJ_CUSTOM_FIELD_VALUES
INNER JOIN
MSP_CUSTOM_FIELDS
ON MSP_CUSTOM_FIELDS.MD_PROP_UID = MSP_PROJ_CUSTOM_FIELD_VALUES.MD_PROP_UID
INNER JOIN
MSP_PROJECTS
ON MSP_PROJECTS.PROJ_UID = MSP_PROJ_CUSTOM_FIELD_VALUES.PROJ_UID
WHERE
MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE IS NULL
ORDER BY
MSP_PROJ_CUSTOM_FIELD_VALUES.PROJ_UID,
MSP_PROJ_CUSTOM_FIELD_VALUES.MD_PROP_UID
However, when I try a new Query to obtain the actual values for the Projects Custom Fields that do use a LookUp Table, I can't seem to find what table in the model I'm supposed to link to the MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE field (the TEXT_VALUE
field has NULL value when CODE_VALUE field isn't NULL)
Any suggestions on how to obtain the actual Projects' custom fields values instead of the Code Value, for Metadata that do use a LookUp Table?
Also, I'm able to run this query only in the Published Database, since the MSP_CUSTOM_FIELDS table is empy in the Draft Database. Why is that?
Awaiting your kind reply,
Sebastián Armas PMO Project ManagerHi Sebastián, rather than directly accessing the database it would be better to use the PSI to get this data. Take a look at the ProjTool sample in the SDK whcih gets this data.
Best regards,
Brian.
Blog |
Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
Project Server TechCenter |
Project Developer Center |
Project Server Help | Project Product Page -
Query for a customer order backlog
Hi,
I'm looking for a sql query (customer order backlog) that list all open article from open orders and not complete supllies which are to be deliver. Who can help?
Regards,
MichaelHi Michael,
SBO has its own report called 'Open Items List' that can be found under sales reports. This can be used to list out all open sales orders.
Alternatively, you could write a query, filtering on the OpenQty field in the RDR1 table to tell you which rows were still open and awaiting delivery. Something like:
select
T1.DocNum,
T1.CardCode,
T1.CardName,
T1.DocDate,
T0.ItemCode,
T0.OpenQty
from
RDR1 T0
inner join ORDR T1 on T0.DocEntry = T1.DocEntry
where
T0.OpenQty > 0
order by
T1.DocNum
Kind Regards,
Owen -
Creating a query for a custom report layout
hello guys,
i am really stuck with this task - i need to populate a report with rows with "0" values based on a particular criteria, here is the example: lets say we have a table BROKERS with company names, their transaction types and cumulative amounts for a current month and all months ever.
COMPANY TRAN_TYPE CURR_MNTH ALL_MNTH
Broker1 CURRENCY_SELL $1000.00 $1500000.00
Broker1 GOLD_SELL $50000.00 $2500000.00
Broker1 GOLD_BUY $80000.00 $8500000.00
Broker1 STOCKS_SELL $35000.00 $3500000.00
table BROKERS does not have a field TRAN_TYPE, but has a field TRAN_TYPE_CD which reffers to another table called TRAN_TYPE_CD_EXPL, where all the codes are explained:
TRAN_TYPE_CD TRAN_TYPE_CD_EXPLD
1 STOCKS_SELL
2 STOCKS_BUY
3 GOLD_SELL
4 GOLD_BUY
5 SILVER_SELL
6 SILVER_BUY
7 COPPER_SELL
8 COPPER_BUY
9 CURRENCY_SELL
10 CURRENCY_BUY
so the results shown above is just a simple join of those two tables:
select b.COMPANY, tt.TRAN_TYPE, b.CURR_MONTH, b.ALL_MNTH
from BROKERS b, TRAN_TYPE_CD_EXPL tt
where b.TRAN_TYPE_CD = tt.TRAN_TYPE_CD;
everything is pretty simple, but here is where the problem starts : the report i am working on should look like this:
COMPANY MARKET TRAN_TYPE CURR_MNTH ALL_MNTH
Broker1 FOREX CURRENCY_SELL $1000.00 $1500000.00
Broker1 FOREX CURRENCY_BUY $0.00 $5500000.00
Broker1 CONTRACTS GOLD_SELL $50000.00 $2500000.00
Broker1 CONTRACTS GOLD_BUY $80000.00 $8500000.00
Broker1 STOCKMARKET STOCKS_SELL $35000.00 $3500000.00
Broker1 STOCKMARKET STOCKS_BUY $0.00 $9500000.00
so let me explain :
firstable, report should contains a column MARKET, which should be populated based on the values in the column TRAN_TYPE, but the thing is there is no table MARKET in database, so each time when you need to populate it in a report or somewhere else, you need to use decode like this (assumed everybody knows where all kind of tran_types belong to):
SELECT DECODE (TRAN_TYPE_CD_EXPL.TRAN_TYPE_CD_EXPLD,
'CURRENCY_SELL', 'FOREX',
'CURRENCY_BUY', 'FOREX',
'STOCKS_SELL', 'STOCKMARKET',
'STOCKS_BUY', 'STOCKMARKET') AS MARKET,
or based on TRAN_TYPE_CD value:
SELECT DECODE (BROKERS.TRAN_TYPE_CD,
9, 'FOREX',
10, 'FOREX',
1, 'STOCKMARKET',
2, 'STOCKMARKET') AS MARKET,
2) problem number 2 is more complicated : the report logic says - is a company has at least one transaction in a particular group (lets say CURRENCY_SELL for market type 'FOREX'), the report should be populated with other tran_types from the market type group with $0 even thou this company did not have any of those transactions during current month. so in this case it should be populated with the rows
Broker1 FOREX CURRENCY_BUY $0.00 $5500000.00
and
Broker1 STOCKMARKET STOCKS_BUY $0.00 $9500000.00
The thing is that it will be executed thru plsql batch on unix, so it must be a single query.
Any ideas and/or suggestions are very appreciated!
Thanks
P.S.
Its oracle 11gr2, with read-only role.Hi,
This sounds like a jo for a partitioned outer join.
Here's one way:
WITH broker_summary AS
SELECT b.company
, tt.tran_type
, b.curr_mnth
, b.all_mnth
FROM broker b
JOIN tran_type_cd_expl tt ON WHERE b.tran_type_cd = tt.tran_type_cd
, market AS
SELECT 'CURRENCY_SELL' AS tran_type, 'FOREX' AS market from DUAL UNION ALL
SELECT 'CURRENCY_BUY', 'FOREX' from DUAL UNION ALL
SELECT 'STOCKS_SELL', 'STOCKMARKET' from DUAL UNION ALL
, got_market_cnt AS
SELECT bs.company
, m.market
, m.tran_type
, b.curr_mnth
, b.all_mnth
, COUNT (*) OVER ( PARTITION BY bs.company
, m.market
) AS market_cnt
FROM market m
LEFT OUTER JOIN broker_summary bs PARTITION BY (bs.company)
ON bs.tran_type = m.tran_type
SELECT company
, market
, tran_type
, NVL (curr_mnth, 0) AS curr_mnth
, NVL (all_mnth, 0) AS all_mnth
FROM got_market_cnt
WHERE market_cnt > 0
ORDER BY company
, market
, tran_type
;If you'd care to post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data, then I could test it.
You should create a market table. Do it once, then you won't have to do it over and over again in every query that needs it. -
Handling DST in SQL Query for UCCX Custom Report
We wrote all custom reports for one of the call centers using our UCCX deployment. One problem we see we will hit in the future is DST. We suggested they use UTC but they wanted to see the call data based off of EST timezone. Right now we are okay because we use -5 to get the correct data but come March we are wondering how to address the issue. What options do we have? How are other people handling DST with the SQL queries for custom reporting? I see that the HR client will determine this based off of the local computer time then gives you the option to use UTC. We have all of our queries in an Excel document that the customer just needs to open and select Refresh All to update their data.
Thanks"case-when" statements are evaluated in order.
so you must do something like this:
SELECT
CASE WHEN <is not number>THEN 'N'
CASE WHEN <is greater than 0>THEN 'Y'
Now "<is greater than 0>" will always have number for input, can't get "not number" error there.
See this thread:
Re: regular expression: integer is between N..M
Edited by: CharlesRoos on May 27, 2010 5:03 AM -
Query for Inactive Responisibilities
Hello Everyone,
Oracle Application Version : 11.5.10.2
OS : HP-UX
I want a query to display in active responsibilities
I have a query using this i am getting user and active responsibilities..
SELECT UNIQUE u.user_id, SUBSTR (u.user_name, 1, 30) user_name,
SUBSTR (r.responsibility_name, 1, 60) responsiblity,
SUBSTR (a.application_name, 1, 50) application, g.end_date
FROM fnd_user u,
fnd_user_resp_groups g,
fnd_application_tl a,
fnd_responsibility_tl r
WHERE g.user_id(+) = u.user_id
AND g.responsibility_application_id = a.application_id
AND a.application_id = r.application_id
AND g.responsibility_id = r.responsibility_id
ORDER BY SUBSTR (user_name, 1, 30),
SUBSTR (a.application_name, 1, 50),
SUBSTR (r.responsibility_name, 1, 60);
Means,
If 100 resp are there i assigned 75 resp to all users
Now i want to know that remaining 25 resp that is i am trying....
Thanks,Hi;
I want a query to display in active responsibilities
I have a query using this i am getting user and active responsibilities..
SELECT UNIQUE u.user_id, SUBSTR (u.user_name, 1, 30) user_name,
SUBSTR (r.responsibility_name, 1, 60) responsiblity,
SUBSTR (a.application_name, 1, 50) application, g.end_date
FROM fnd_user u,
fnd_user_resp_groups g,
fnd_application_tl a,
fnd_responsibility_tl r
WHERE g.user_id(+) = u.user_id
AND g.responsibility_application_id = a.application_id
AND a.application_id = r.application_id
AND g.responsibility_id = r.responsibility_id
ORDER BY SUBSTR (user_name, 1, 30),
SUBSTR (a.application_name, 1, 50),
SUBSTR (r.responsibility_name, 1, 60);
If 100 resp are there i assigned 75 resp to all users
Now i want to know that remaining 25 resp that is i am trying....Did you try to use "minus". I mean if you can query to all resp. than use minus and upper sql query. I belive it will gives you difference
Hope it helps
Regard
Helios -
Query for customer and its all the underlying sites in AR
Hi Expert,
Please help me to build a query for a customer and its all the underlying sites .
ThanksPlease check this thread:
Running Total in QLD
Thanks,
Gordon -
We let our paid contract expire and therefore all active in-app purchases stopped working. I just filled it out and it is now in-effect, but does anyone know roughly how long before these in-app purchases will become active again?
Hi ,
I'm very sorry to hear of the problems you have had moving to pay as you go.
Please can you give customer service a call and ask to speak to the pay monthly retentions team who will be able to fix this issue for you.
Click here for contact details.
Thanks
James -
Customer support html (html service) - how can i query for 'closed' SRs
hi,
11.5.10.2
in customer support html (html service - CSZ), is there any facility to query for SRs that are in 'closed' status?
currently, a SR in 'closed' status can only be queried if agent knows the exact SR number. on Advanced Search page, even though the application allows 'closed' status to be selected, it does not return any record.
help is appreciated, as this is critical to our business.
regards.You can search for Closed SRs. Ensure that the search criteria 'Active' is set to 'No'. This will return back closed SRs.
Who is the customer? Can you provide some more details on the implementation? (you can send me an email to [email protected])
Thanks.
Edited by: dejoseph on Mar 31, 2010 12:00 PM -
How to query opening balance for all customer or Vendor for an speci. date
Hi,
How to query opening balance for all customer or Vendor for an specific date?
Example:
put any date and query will show all customer/ Vendor that date opening/current balance.
Regards,
MizanHi mizan700 ,
Try this
SELECT T0.[DocNum] As 'Doc No.', T0.[CardCode] As 'Customer Code',
T0.[CardName] As 'Customer Name',(T0.[DocTotal]-T0.[PaidSys]) As 'O/S Balance'
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
INNER JOIN OCRG T2 on T1.GroupCode = T2.GroupCode
INNER JOIN INV1 T3 ON T0.DocEntry = T3.DocEntry
WHERE T0.[DocStatus] ='O'
AND
(T0.[DocDate] >='[%0]' AND T0.[DocDate] <='[%1]')
Regards:
Balaji.S -
Approval Query for a specific customer group
Dear Experts,
Following is the scenario, customer deals with whole sale and retail customers group. The client wishes to ensure that If the whole sales customer group account balance greater than zero then while making a sales order or invoice it should trigger approval.
SaravananHi Saravnan......
Thy this Approval Query and just put the Group Code for your customer in this group code's inverted comma....
SELECT Distinct 'TRUE' From OCRD T0 Where T0.Balance>0 and GroupCode=' '
And T0.CardCode=$[ORDR.CardCode.0]
If above does not work then use below...
SELECT Distinct 'TRUE' From OCRD T0 Where T0.Balance>0 and GroupCode=' '
And T0.CardCode=$[$4.0.0]
Regards,
Rahul -
Write query for Customer recievable Report.
*1.No concrete solution given to take project wise, bill wise. 2. Opening dues break up - project wise. Bill wise. 3. Aging days not able to select the required interval. Only standard intervals are available. 4. How to find the exact payment receivable for an customer. Pl tell me. How write a query in query generator..Sl no V.Code Customer Name Project Code Prj Type Series In no Posting Date Due Date Future Remit 0 - 30 30 - 60 60 - 90 90 + Total
For getting Customer receivable Aging Reports. Its SAP B1 2005 Version.*Hi,
Try this. May be this will help you.
select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit GBP',syscred 'Credit GBP',
case JDT1.transtype
when '-2' then 'OB'
when '13' then 'IN'
when '16' then 'DN'
when '24' then 'RC'
else 'Other'
end 'Type',
Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), refdate, 103)'Posting Date' ,
CONVERT(VARCHAR(10), duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,
CASE
when DATEDIFF(dd,taxdate,current_timestamp) < 31
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "0-30 days",
case when (datediff(dd,taxdate,current_timestamp) > 30
and datediff(dd,taxdate,current_timestamp)< 61)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "31 to 60 days",
case when (datediff(dd,taxdate,current_timestamp) > 60
and datediff(dd,taxdate,current_timestamp)< 91)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "61 to 90 days",
CASE
when DATEDIFF(dd,taxdate,current_timestamp) > 90
then
case
when syscred 0 then syscred * - 1
else sysdeb
end
end "90 + days"
from JDT1,OCRD where JDT1.shortname = OCRD.cardcode and cardtype = 'C' and intrnmatch = '0'
ORDER BY OCRD.CARDCODE, taxdate
Thanks
Pradnya -
Transaction code thro' SAP Query for customer spefific report
hi experts,
how to create transaction code (using SE43-) for the sap query created on own??
I have created the following required for a customer specific report
1.Infoset thro sq02
2.user group thro sq03 and assigned it to infoset
3.query thro sq01 and saved it with text
earlier i have used logical database PNPCE ( relevant for PA and payroll modules reports)
using sq01 , go to basic list , selected required infotypes and fields and
then selected, SAP List viewer for viewing and i get the report.
Now my question is how to create a separate transaction code for this sap query which i created
should i use SE43( area menu maintenance and area class???_)
should i create a variant and go to SE43??
advice solicited
snrHello
when you excecute the query in right han side corner you can get the program name
go to se80 select program & type this name and then you can create a tcode for that prog in SE80
reward points if helpful.
the prog name will be something like : AQZZ/SAPQUERY/* " ur query name
you can search for the name also in this manner
Maybe you are looking for
-
Can I make one iphoto library from two time machine back-ups?
Hi I have recently purchased a new Mac Book. I previously had two MacBooks, which I backed up with time machine onto two separate external hard drives. I did a straight transfer of all data from one of these time time machine back-ups to my new lapto
-
Adding and Removing an Instance in LiveCycle Designer 8.2
Good Morning, I am just beginning to use LiveCycle Designer 8.2 which was packaged with Adobe Acrobat 9.0 and I was just given a short timelined project for a form to be created for which I would like to include a + and - button to add and remove ins
-
I used iCloud control panel to,wirelessly sync my iPad II with outlook 2010, windows xp pro. First sync was successful. All subsequent syncs have failed with an error message. Also, when re synching, I didn't see an option to sync only changes.
-
Dynamic select with fieldsymbol
Dear all, I wanted to write a dynamic select for this code. SELECT-OPTIONS: so_gjahr FOR bkpf-gjahr, so_belnr FOR bkpf-belnr, so_bukrs FOR bkpf-bukrs, so_aufnr FOR aufk-aufnr, so_vbeln F
-
Detection of Connected Device through Java code at Runtime.
Hello All, In my Java application, I want to detect any Device/ Drive/ USB/ Storage Device which is connected at runtime or before application starts. Also I want to know which device is connected first. If you have any idea about this please tell me