An Oracle application with AS

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.