NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

select CURRENT_DATE as Refresh_Date, t1.merchant_account_nbr as Child_MID,
extract(year from t1.post_date) as Metric_Year,
case when extract(month from t1.post_date) in (1, 2, 3) then 1
when extract(month from t1.post_date) in (4, 5, 6) then 2
when extract(month from t1.post_date) in (7, 8, 9) then 3
when extract(month from t1.post_date) in (10, 11, 12) then 4
end as Metric_Quarter,
extract(month from t1.post_date) as Metric_Month_Num,
TO_CHAR(t1.post_date, 'Month') as Metric_Month_Name,
case when extract(day from t1.post_date) <= 7 then 1
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then 2
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then 3
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then 4
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then 5
end as Metric_Week,
case when extract(day from t1.post_date) <= 7 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-1', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-8', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-15', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-22', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-29', 'YYYY-MM-DD')
end as Start_Of_Week,
case when extract(day from t1.post_date) <= 7 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-7', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-14', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-21', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-28', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-' || extract(day from LAST_DAY(t1.post_date)), 'YYYY-MM-DD')
end as End_Of_Week,
case when extract(day from t1.post_date) <= 28 then 7
when extract(day from t1.post_date) > 28 then extract(day from LAST_DAY(t1.post_date)) - 28
end as Num_Days_In_Week,
round(sum(case when t1.transaction_code = '253' then abs(transaction_amt) when t1.transaction_code = '255' then -1 * abs(transaction_amt) end), 2) as Net_Credit_Sales,
sum(case when t1.transaction_code = '253' then 1 when t1.transaction_code = '255' then -1 end) as Net_Transactions,
case when sum(case when t1.transaction_code = '253' then 1 when t1.transaction_code = '255' then -1 end) = 0 then 0
when sum(case when t1.transaction_code = '253' then 1 when t1.transaction_code = '255' then -1 end) <> 0 then round((sum(case when t1.transaction_code = '253' then abs(transaction_amt) when t1.transaction_code = '255' then -1 * abs(transaction_amt) end) / sum(case when t1.transaction_code = '253' then 1 when t1.transaction_code = '255' then -1 end)), 2) end as Avg_Ticket

from merchant_settlement_fact t1
where t1.merchant_account_nbr in ('5348120285317558','5348120285317632'
and t1.transaction_code in ('253', '255')
and post_date >= TO_DATE('2021-01-01', 'YYYY-MM-DD')
and post_date <= TO_DATE('2023-04-30', 'YYYY-MM-DD')
group by CURRENT_DATE, t1.merchant_account_nbr, extract(year from t1.post_date), (case when extract(month from t1.post_date) in (1, 2, 3) then 1
when extract(month from t1.post_date) in (4, 5, 6) then 2
when extract(month from t1.post_date) in (7, 8, 9) then 3
when extract(month from t1.post_date) in (10, 11, 12) then 4
end),
extract(month from t1.post_date),
TO_CHAR(t1.post_date, 'Month'),
(case when extract(day from t1.post_date) <= 7 then 1
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then 2
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then 3
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then 4
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then 5
end),
case when extract(day from t1.post_date) <= 7 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-1', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-8', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-15', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-22', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-29', 'YYYY-MM-DD')
end,
case when extract(day from t1.post_date) <= 7 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-7', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-14', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-21', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-28', 'YYYY-MM-DD')
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then TO_DATE(extract(year from t1.post_date) || '-' || extract(month from t1.post_date) || '-' || extract(day from LAST_DAY(t1.post_date)), 'YYYY-MM-DD')
end,
case when extract(day from t1.post_date) <= 28 then 7
when extract(day from t1.post_date) > 28 then extract(day from LAST_DAY(t1.post_date)) - 28
end
order by CURRENT_DATE, t1.merchant_account_nbr, extract(year from t1.post_date), (case when extract(month from t1.post_date) in (1, 2, 3) then 1
when extract(month from t1.post_date) in (4, 5, 6) then 2
when extract(month from t1.post_date) in (7, 8, 9) then 3
when extract(month from t1.post_date) in (10, 11, 12) then 4
end),
extract(month from t1.post_date), (case when extract(day from t1.post_date) <= 7 then 1
when extract(day from t1.post_date) > 7 and extract(day from t1.post_date) <= 14 then 2
when extract(day from t1.post_date) > 14 and extract(day from t1.post_date) <= 21 then 3
when extract(day from t1.post_date) > 21 and extract(day from t1.post_date) <= 28 then 4
when extract(day from t1.post_date) > 28 and extract(day from t1.post_date) <= 31 then 5
end);
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.