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
GO | |
/*------------------------------------------------ | |
description: 取最大公約數 : 輾轉相除法(歐幾里德算法) | |
author: Robin | |
date: 2022/10/26 | |
testing code: | |
-------------------------------------------------- | |
select 3, dbo.Math_GetGys(3, 3) | |
select 3, dbo.Math_GetGys(9, 6) | |
select 6, dbo.Math_GetGys(12, 6) |
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
/*------------------------------------------------ | |
description: convert number of minutes to hh:mm format | |
author: Robin | |
date: 2022/09/28 | |
testing code: | |
-------------------------------------------------- | |
PRINT dbo.FormatMinutesToHHMM(15) | |
PRINT dbo.FormatMinutesToHHMM(90) | |
PRINT dbo.FormatMinutesToHHMM(125) | |
-------------------------------------------------- |
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
return System.DateTime.Today.ToString(format, new System.Globalization.CultureInfo("en-US")); |
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
<html> | |
<body> | |
<div id="" style="width:100px; height:1500px; background-color:gold;"></div> | |
</body> | |
<script> | |
window.addEventListener("scroll",()=>{ | |
console.log("----------"); | |
console.log(window.innerHeight);//視窗高度 | |
console.log(window.scrollY);//捲軸垂值位移量 | |
console.log(document.body.scrollHeight); |
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
using Microsoft.Win32; | |
/// <summary> | |
/// 開機登入自動執行機碼相關操作 | |
/// </summary> | |
public class RegistryKeyHelper | |
{ | |
public enum CheckResult | |
{ | |
NotExistKey, |
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
/*模擬 100 筆資料, 時間值範圍為 2022-01-18 23:59:59.950 ~ 2022-01-19 00:00:00.050*/ | |
DECLARE @WorkOrder AS TABLE(MS int, ModifiedDate datetime); | |
DECLARE @Current int = 0 | |
, @TotalRows int = 100 | |
, @StartTime datetime = CONVERT(datetime, '2022-01-18 23:59:59') | |
, @StartMilliSec int = 950; | |
WHILE(@Current < @TotalRows) |
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 @SourceData AS TABLE(DOCNO varchar(16), TRANS_DATE date, AMOUNT int) | |
insert into @SourceData(DOCNO, TRANS_DATE, AMOUNT) | |
select DOCNO='2021011501', TRANS_DATE=convert(date,'2021-01-15'),AMOUNT=300 union | |
select DOCNO='2021052601', TRANS_DATE=convert(date,'2021-05-26'),AMOUNT=400 union | |
select DOCNO='2021060701', TRANS_DATE=convert(date,'2021-06-07'),AMOUNT=300 union | |
select DOCNO='2021060801', TRANS_DATE=convert(date,'2021-06-08'),AMOUNT=400 union | |
select DOCNO='2021060901', TRANS_DATE=convert(date,'2021-06-09'),AMOUNT=700 union | |
select DOCNO='2021071001', TRANS_DATE=convert(date,'2021-07-10'),AMOUNT=800 union | |
select DOCNO='2021071101', TRANS_DATE=convert(date,'2021-07-11'),AMOUNT=900 union |
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
/* | |
將以下原始資料 | |
依各品牌匯總數量、金額的統計表 | |
*/ | |
select BRAND='ASUS', QTY=1, AMT=200 | |
union all | |
select BRAND='BENQ', QTY=1, AMT=200 | |
union all | |
select BRAND='ASUS', QTY=1, AMT=200 |
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 @TempTable AS TABLE (ID int IDENTITY(1,1), AMT01 numeric(12,4)); | |
insert into @TempTable(AMT01) | |
values(100),(200),(300); | |
select P1.* | |
, [最新一筆] = LAST_VALUE(AMT01) over(order by ID) | |
, [上一筆] = LAG(AMT01) over(order by ID) | |
, [下一筆] = LEAD(AMT01) over(order by ID) | |
from @TempTable P1 |
NewerOlder