Skip to content

Instantly share code, notes, and snippets.

@Andy-Aoh
Andy-Aoh / RealNumbersInfinity.cs
Created March 17, 2019 14:20
Real Numbers Infinity loop
public class RealNumbersInfinity : IEnumerator<int>
{
private int i = 0;
private int limit;
public RealNumbersInfinity(int limit)
{
this.limit = limit;
}
public int Current
@Andy-Aoh
Andy-Aoh / AsyncAwait.cs
Last active March 12, 2019 13:23
Async Await test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AwaitTest
{
select * from sys.database_files
DBCC SHRINKFILE
USE [DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SELECT *
FROM master.sys.extended_procedures;
GO
USE TSQL2012;
SELECT custid, region
FROM Sales.Customers
ORDER BY CASE
WHEN (region IS NULL) THEN 1
WHEN region IS NOT NULL THEN 0
END, region
SELECT *
SELECT TOP(3) shipcountry, AVG(freight) AS avgfreight
FROM Sales.Orders
GROUP BY shipcountry,YEAR(orderdate)
HAVING YEAR(orderdate)=2007
order by avgfreight DESC
USE TSQL2012;
SELECT orderid,SUM(qty*unitprice) as totalvalue
FROM Sales.OrderDetails
GROUP BY orderid
HAVING (SUM(qty*unitprice)) >10000
ORDER BY totalvalue DESC
SELECT orderid, orderdate, custid, empid
FROM Sales.Orders
WHERE EOMONTH(orderdate)=orderdate
select orderid, orderdate, custid, empid
FROM Sales.Orders
WHERE YEAR(orderdate)=2007 AND MONTH(orderdate)=6