With TMP1 as (
Select
T. " ID ",
T.username,
T.productid,
T.operateid,
T.normalids,
T.operatetime
From Trsaaa_statisticripedata t
Left join Idsuser T2 on T.username=t2.username
where T.operatetime < (to_date (' 2014-01-01 ', ' yyyy-mm-dd ')-
To_date (' 1970-01-01 ' | | Tz_offset (Sessiontimezone), ' Yyyy-mm-dd hh:mi ') * 86400000
and T.operatetime > (to_date (' 2013-01-01 ', ' yyyy-mm-dd ')-
To_date (' 1970-01-01 ' | | Tz_offset (Sessiontimezone), ' Yyyy-mm-dd hh:mi ') * 86400000
and T.statistictype = ' TRADING '
),
TMP2 as (
Select t.entry_id entry_id
From [email protected] t-start with t.entry_id in (' 52 ')
Connect by t.parent_id = Prior t.entry_id
),
Tmp3 as (
SELECT DISTINCT
Tmp1. " ID ",
Tmp1.username,
Tmp1.productid,
Tmp1.operateid,
Min (TMP1.OPERATETIME-T4. BEGINTIME) as Touchtime
From TMP1 left join trsaaa_contract T4
On (Tmp1.username = T4.username and (tmp1.operatetime between T4. BEGINTIME and T4. ENDTIME or (Tmp1.operatetime > T4. BEGINTIME and T4. ENDTIME = 0)))
Left join TMP2 on (1=1)
Where (Tmp1.normalids like '%, ' | | | tmp2.entry_id) or (tmp1.normalids like '%, ' | | tmp2.entry_id | | ‘,%‘))
GROUP by TMP1. " ID ",
Tmp1.username,
Tmp1.productid,
Tmp1.operateid
)
SELECT DISTINCT
T.username as user account,
T.nickname as user name,
T3.typename as user type,
case when T4. " Chargingway "= ' ITEM ' Then
' Billed by Bar '
when T4. " Chargingway "= ' KIND ' Then
' Billed by class '
when T4. " Chargingway "= ' NO ' Then
' No billing '
when T4. " Chargingway "= ' after ' Then
' After pay '
Else
T4. " Chargingway "
End as billing type,
Case T.validdata If 1 then ' effective ' else ' invalid ' end as trading validity,
T.normalids as Normalids,
T.feeid as Feeid,
T.feepath as Feepath,
To_char (to_date (' 01/01/1970 ' | | Tz_offset (Sessiontimezone), ' mm/dd/yyyy hh:mi ') +
Operatetime/(+ *), ' YYYY/MM/DD ') as trading hours,
T.productid as manuscript ID,
T.producttitle as manuscript title,
T.operateid as trading serial number,
T.price as transaction price,
T.statistictype as transaction type
From Trsaaa_statisticripedata t
INNER join Tmp3 on T. " ID "= Tmp3." ID "
Left join trsaaa_usertypemapping T3 on T.username=t3.username
Left joins trsaaa_contract t4 on (t.username = T4.username and T.operatetime-t4. BEGINTIME = Tmp3.touchtime);
An Oracle application with AS