Skip to content

Instantly share code, notes, and snippets.

View burahant's full-sized avatar

Burahan T. burahant

  • Bangkok, Thailand
View GitHub Profile
@burahant
burahant / GetQuarterlyCategorySales.sql
Created October 1, 2025 10:47
(Difficulty level 4): Create a stored procedure that takes a year as a parameter and displays a summary report of sales by category in each quarter of that year, presented in a pivot table format
create procedure [dbo].[GetQuarterlyCategorySales]
@year int
as
begin
select
CategoryName,
[1] as Q1,
[2] as Q2,
[3] as Q3,
[4] as Q4
@burahant
burahant / GetTopSpendingCustomers.sql
Last active October 1, 2025 10:48
(Difficulty level 3): Find the customer with the highest total spending in each country, considering only orders with more than 10 items and a total order value greater than $1,000.
create procedure [dbo].[GetTopSpendingCustomers]
as
begin
with customerOrders as (
select
c.CustomerID,
c.CompanyName,
c.Country,
sum(od.Quantity) as Quantity,
sum(od.UnitPrice * od.Quantity) as TotalSpending