This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with seq (yr, jan1, jul4) as ( | |
| select | |
| 2001 as yr, | |
| cast('2001-01-01' as datetime) as jan1, | |
| cast('2001-07-04' as datetime) as jul4 | |
| union all | |
| select | |
| yr + 1, | |
| dateadd(year, 1, jan1), | |
| dateadd(year, 1, jul4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare @row_count int = 100; | |
| with seq (s, d, c) as ( | |
| select | |
| 1 as s, | |
| cast('2000-01-01' as datetime) as d, | |
| char(1) as c | |
| union all | |
| select | |
| s + 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define row_count = "100" | |
| select | |
| level as s, | |
| to_date((2000+level)*10000 + 0101, 'yyyymmdd') as d, | |
| chr(level) as c | |
| from dual | |
| connect by level <= &row_count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare @shift int = 6 | |
| select | |
| test_dt, | |
| concat(year(dateadd(month, -@shift, test_dt)), '-', year(dateadd(month, 12-@shift, test_dt))) as fisc_year, | |
| dateadd(month, @shift, datename(year, dateadd(month, -@shift, test_dt)) + '0101') as fisc_start | |
| from (values | |
| (getdate()), | |
| (cast('2014-03-31' as date)), | |
| (cast('2014-04-01' as date)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define shift = "6" | |
| with v as ( | |
| select | |
| trunc(sysdate - floor(dbms_random.value()*1000)) as test_dt | |
| from dual | |
| connect by level <= 10 | |
| ) | |
| select | |
| test_dt, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with yr_tbl as ( | |
| select | |
| 2000 + level as yr, | |
| to_date(101 + (2000+level)*10000, 'yyyymmdd') as jan1, | |
| to_date(704 + (2000+level)*10000, 'yyyymmdd') as jul4 | |
| from dual | |
| connect by level <= 100 | |
| ) | |
| select | |
| yr, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with utc_tm as ( | |
| select to_timestamp_tz('1970-01-01 00:00:00 +00:00') + numtodsinterval(level - 1, 'hour') as utc_tm | |
| from dual connect by level <= 1000000 | |
| ), utc_lcl as ( | |
| select | |
| utc_tm, | |
| cast(utc_tm as timestamp with local time zone) as lcl_tm, | |
| (cast(utc_tm as date) - cast(cast(utc_tm as timestamp with local time zone) as date))*24 as interval_h | |
| from utc_tm | |
| ), interval_compare as ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with col_info as ( | |
| select | |
| c.owner, | |
| c.table_name, | |
| c.column_name, | |
| c.column_id, | |
| pc.column_name as PK_COL | |
| from | |
| all_tab_cols c join all_constraints p on | |
| c.owner = p.owner and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with col_info as ( | |
| select | |
| c.owner, | |
| c.table_name, | |
| c.column_name, | |
| c.column_id, | |
| pc.column_name as PK_COL, | |
| max(c.column_id) over() as max_id | |
| from | |
| all_tab_cols c join all_constraints p on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doTask1(){ | |
| // Create a new process | |
| var defer = $.Deferred(); | |
| // Start main task in the process | |
| setTimeout(function(){ | |
| var rslt = Math.floor(Math.random() * 10); | |
| log("Task 1 returned " + rslt); | |
| // Main task is finished. |