Questions
stringlengths
21
143
SQL Query
stringlengths
50
718
What is the forecasted sales for 2022 for Department ABC?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2022 and [department name] = 'abc'
What is the forecasted sales for 2022 for Location AYZ?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2022 and location = 'ayz'
What is the forecasted sales for 2022 for Account name Depreciation?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2022 and [Account name] like '%depreciation%'
What is the forecasted sales for 2022 for Geography AY?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2022 and gepgraphy = 'ay'
Entity Alpha has how many unique departments?
select count( distinct (department name)) from forecasted_table where enity = 'Alpha'
Entity Alpha has how many unique locations?
select count( distinct (location)) from forecasted_table where enity = 'Alpha'
Entity Alpha has how many unique geographies?
select count( distinct (geography)) from forecasted_table where enity = 'Alpha'
Entity Alpha has how many unique accounts?
select count( distinct (account name)) from forecasted_table where enity = 'Alpha'
find unique departments?
select count( distinct (department name)) from forecasted_table
how many unique locations are there?
select count( distinct (location)) from forecasted_table
find unique accounts?
select count( distinct (account name)) from forecasted_table
find unique entities?
select count( distinct (entity)) from forecasted_table
What is the total forecasted sales for 2022 for location L02?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 and [location] = 'L02'
What is the total forecasted sales for 2022 for print?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 and [account name] like '%print%'
What is the quarter 3 sales for Location L03?
select sum(isnull(sales_forecast,0)) from forecasted_table where quarter = 3 and [location] = 'L03'
What is the quarter 3 sales for Entity Alpha?
select sum(isnull(sales_forecast,0)) from forecasted_table where quarter = 3 and [entity] = 'alpha'
What is the quarter 3 sales for Department DL08?
select sum(isnull(sales_forecast,0)) from forecasted_table where quarter = 3 and [department name] = 'DL08'
What is the quarter 3 sales for Sales discount?
select sum(isnull(sales_forecast,0)) from forecasted_table where quarter = 3 and [account name] like '%sales discount%'
How many years of forecasted data do we have in the table?
select distinct (year(date)) from forecasted_table
For Entity Alpha, what is the latest forecast available?
select max(year(date)), max(month(date)) from forecasted_table where [entity] = 'Alpha'
what is the latest forecast available for location L76?
select max(year(date)), max(month(date)) from forecasted_table where [location] = 'L76'
What is the latest forecast available for Geography GL877?
select max(year(date)), max(month(date)) from forecasted_table where [geography] = 'GL877'
What is the average forecasted sales per entity?
select entity, avg(isnull(sales_forecast,0)) from forecasted_table group by entity
What is the average forecasted sales per department?
select [department name], avg(isnull(sales_forecast,0)) from forecasted_table group by [department name]
What is the average forecasted sales per location?
select location, avg(isnull(sales_forecast,0)) from forecasted_table group by location
What is the average forecasted sales per account?
select [account name], avg(isnull(sales_forecast,0)) from forecasted_table group by [account name]
What is the average forecasted sales per geography?
select geography, avg(isnull(sales_forecast,0)) from forecasted_table group by geography
Find the total sales for 2023 for accounts that contain "merchandise sales"
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [account name] like '%merchandise sales%'
Find the total sales for 2023 for department name that contain "DL"
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [department name] like '%DL%'
Find the total sales for 2023 for accounts that start with "merchandise sales"
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [account name] like 'merchandise sales%'
Find the total sales for 2023 for department name that start with "DP"
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [account name] like 'DP%'
Find the unique departments that contain "DP"
select distinct [department name] from forecasted_table where [department name] like '%dp%'
Find the unique accounts that contain "hr"
select distinct [account name] from forecasted_table where [account name] like '%hr%'
find the total sales for year 2023 for locations- ABC, AHC, and JIE
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [location] in ('ABC', 'AHC' , 'JIE')
find the total sales for year 2023 for department name- DL001,DL002, AND DL003
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [department name] in ('DL001', 'DL002', 'DL003')
find the total sales for year 2023 for geography- GL001,GL002, AND GL003
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [geography] in ('GL001', 'GL002', 'GL003')
find the total sales for year 2023 for entity- Alpha and beta
select sum(isnull(sales_forecast,0)) from forecasted_table where year(date) = 2023 and [entity] in ('alpha', 'beta')
Find accounts with sales forecast between 20000-30000 in 2023?
select [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2023 group by [account name] having sum(isnull(sales_forecast,0)) >=20000 and sum(isnull(sales_forecast,0)) < 30000
Find departments with sales forecast between 50000-80000 in 2023?
select [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2023 group by [department name] having sum(isnull(sales_forecast,0)) >=50000 and sum(isnull(sales_forecast,0)) < 80000
What is the department number for Finance
select distinct [department number] from forecasted_table where [department name] like '%Finance%'
What is the account number for Overtime - (Hrly) - Corporate account
select distinct [account number] from forecasted_table where [account name] like '%Overtime - (Hrly) - Corporate%'
Fine total sales in 2023 for account 401?
select sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2023 where [account number] = 401
What is the total sales in 2022 for department number FD32
select sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2023 where [department number] = 'FD32'
How much is forecasted department spend on Brand Marketing in 2023
select sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2023 and [department name] like '%Brand Marketing%'
What is the forecasted location wise sales for Alpha in year 2022?
select location ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 and entity = 'alpha' group by location
Find forecasted sales in 2022 by department for location AL001?
select [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 and location = 'al001' group by [department name]
find forecasted 2022 account wise sales for department depreciation?
select [account name] ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 and [department name] = 'depreciation' group by [account name]
find the forecasted sales by Locations for year 2022?
select location ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by location
what is forecasted sales across different departments for year 2022?
select [department name] ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name]
find forecasted sales by geographies for year 2022?
select geography ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography
what is the forecasted sales across different accounts for year 2022?
select [account name] ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name]
find forecasted sales by entities for year 2022?
select entity ,sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by entity
find the top 2 location in Alpha projected to have highest sales_forecast for 2022
select top 2 [location], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by location order by sales_forecast desc
find the top 5 locations in Alpha projected to have highest sales_forecast for 2022
select top 5 [location], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by location order by sales_forecast desc
find the top 3 geography in Alpha projected to have highest sales_forecast for 2022
select top 3 [geography], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography order by sales_forecast desc
find the top 10 departments in Alpha projected to have highest sales for 2022
select top 10 [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name] order by sales_forecast desc
Which Department has the lowest sales forecast in the year 2022?
select top 1 [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name] order by sales_forecast asc
Which account has lowest sales in the year 2022?
select top 1 [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 order by sales_forecast asc
Which location has lowest sales in the year 2022?
select top 1 [location], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by location order by sales_forecast asc
Which geography has lowest sales in the year 2022?
select top 1 [geography], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography order by sales_forecast asc
Which entity has lowest sales in the year 2022?
select top 1 [entity], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by entity order by sales_forecast asc
Which Department has highest sales in the year 2022?
select top 1 [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name] order by sales_forecast desc
Which Entity has the highest forecasted sales for the current year?
select top 1 entity, sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = year(getdate()) group by entity order by sales_forecast desc
Which location has the highest forecasted sales for the current year?
select top 1 location, sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = year(getdate()) group by location order by sales_forecast desc
Which account has the highest forecasted sales for the current year?
select top 1 [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = year(getdate()) group by [account name] order by sales_forecast desc
Which geography has the highest forecasted sales for the current year?
select top 1 geography, sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = year(getdate()) group by geography order by sales_forecast desc
find the breakdown of forecasted sales for 2022 for each Geography by Department?
select geography, [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography, [department name]
find the breakdown of forecasted sales for 2022 for each account by Department?
select [account name], [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name], [department name]
find the breakdown of forecasted sales for 2022 for each Geography by location?
select geography, [location], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography, [location]
What are the forecasted sales figures for each account over year 2022 sort by descending order?
select [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name] order by sales_forecast desc
What are the forecasted sales figures for each account over year 2022 sort by ascending order?
select [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name] order by sales_forecast asc
What are the forecasted sales figures for each department over year 2022 sort by descending order?
select [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name] order by sales_forecast desc
What are the forecasted sales figures for each department over year 2022 sort by ascending order?
select [department name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name] order by sales_forecast asc
What are the forecasted sales figures for each location over year 2022 sort by ascending order?
select [location], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [location] order by sales_forecast asc
What are the forecasted sales figures for each location over year 2022 sort by descending order?
select [account name], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name] order by sales_forecast desc
What is the average forecasted sales for year 2022 in each location?
select location, avg(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by location
What is the average forecasted sales for year 2022 in each department?
select [department name], avg(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department name]
What is the average forecasted sales for year 2022 in each entity?
select entity, avg(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by entity
What is the average forecasted sales for year 2022 in each account?
select [account name], avg(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account name]
What is the average forecasted sales for year 2022 in each geography?
select geography, avg(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by geography
What is the average forecasted sales in each location?
select location, avg(isnull(sales_forecast,0)) from forecasted_table group by location
What is the average forecasted sales in each department?
select [department name], avg(isnull(sales_forecast,0)) from forecasted_table group by [department name]
What is the average forecasted sales in each entity?
select entity, avg(isnull(sales_forecast,0)) from forecasted_table group by entity
Account wise projected sales for Wholesale department in 2022?
select [account name], sum(isnull(sales_forecast,0)) from forecasted_table where [department name] = 'wholesale' and year(Date) = 2022 group by [account name]
Location wise projected sales for Sales discount account in 2022?
select location, sum(isnull(sales_forecast,0)) from forecasted_table where [account name] = 'sales discount' and year(Date) = 2022 group by location
Geography wise projected sales for ABC entity in 2022?
select geography, sum(isnull(sales_forecast,0)) from forecasted_table where [entity] = 'abc' and year(Date) = 2022 group by geography
Entity wise projected sales for Wholesale department in 2022?
select entity, sum(isnull(sales_forecast,0)) from forecasted_table where [entity] = 'abc' and year(Date) = 2022 group by entity
What is the average forecasted sales in each account?
select [account name], avg(isnull(sales_forecast,0)) from forecasted_table group by [account name]
What is the average forecasted sales in each geography?
select geography, avg(isnull(sales_forecast,0)) from forecasted_table group by geography
Departments projected to have yearly sales below 150,000 are termed as "Low expense departments". How many such departments do we have in 2022?
select count(*) from (select [department number], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [department number] having sum(isnull(sales_forecast,0)) < 150000)
Accounts projected to have yearly sales below 50,000 are termed as "Low activity accounts". How many such accounts do we have in 2022?
select count(*) from (select [account number], sum(isnull(sales_forecast,0)) from forecasted_table where year(Date) = 2022 group by [account number] having sum(isnull(sales_forecast,0)) < 50000)
Location wise projected sales for Wholesale department in 2022?
select location, sum(isnull(sales_forecast,0)) from forecasted_table where [department name] like '%wholesale%' and year(Date) = 2022 group by location
find average sales for each entity, geography, department and location for the year 2022?
select entity, geography , [department name], location, sum(isnull(sales_forecast,0))/count(distinct [department number]) from forecasted_table where year(date) = 2022 group by entity, geography ,[department name], location
find average sales per department for each entity, geography and location?
select entity, geography , location, sum(isnull(sales_forecast,0))/count(distinct [department number]) from forecasted_table group by entity, geography , location
For product cost account, what is the forecasted sales growth in the month of 5 year 2022 compared to previous month?
SELECT [account name],year(Date),month(date), case when LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [account name] ORDER BY year(Date),month(date)) = 0 then null else decimal(((sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [account name] ORDER BY year(Date),month(date))) /LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [account name] ORDER BY year(Date),month(date)))*100),2) end as sales_forecast_growth FROM forecasted_table where [account name] like '%product cost%' and year(date) = 2022 and month(date) = 5 group by [account name] ,year(Date),month(date) ORDER BY [account name] ,year(Date),month(date)
For finance department, what is the forecasted sales growth in the month of 7 year 2022 compared to previous month?
SELECT [department name],year(Date),month(date), case when LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date)) = 0 then null else decimal(((sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date))) /LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date)))*100),2) end as sales_forecast_growth FROM forecasted_table where [department name] = 'finance' and year(date) = 2022 and month(date) = 7 group by [department name] ,year(Date),month(date) ORDER BY [department name] ,year(Date),month(date)
What is the forecasted sales growth for entity ABC in the month of 6 year 2022 compared to previous month?
SELECT [entity],year(Date),month(date), case when LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [entity] ORDER BY year(Date),month(date)) = 0 then null else decimal(((sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [entity] ORDER BY year(Date),month(date))) /LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [entity] ORDER BY year(Date),month(date)))*100),2) end as sales_forecast_growth FROM forecasted_table where [entity] = 'ABC' and year(date) = 2022 and month(date) = 6 group by [entity] ,year(Date),month(date) ORDER BY [entity] ,year(Date),month(date)
What is the forecasted sales growth for Location AB23 in the month of 5 year 2022 compared to previous month?
SELECT [location],year(Date),month(date), case when LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [location] ORDER BY year(Date),month(date)) = 0 then null else decimal(((sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [location] ORDER BY year(Date),month(date))) /LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [location] ORDER BY year(Date),month(date)))*100),2) end as sales_forecast_growth FROM forecasted_table where [location] = 'AB23' and year(date) = 2022 and month(date) = 5 group by [location] ,year(Date),month(date) ORDER BY [location] ,year(Date),month(date)
For customer service department , what is the forecasted sales growth in the month of 2 year 2022 compared to previous month?
SELECT [department name],year(Date),month(date), case when LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date)) = 0 then null else decimal(((sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date))) /LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date),month(date)))*100),2) end as sales_forecast_growth FROM forecasted_table where [department name] = 'customer service' and year(date) = 2022 and month(date) = 2 group by [department name] ,year(Date),month(date) ORDER BY [department name] ,year(Date),month(date)
What is the difference in forecasted sales for HR Department for year 2023 Vs 2022
SELECT [department name],year(Date), sum(isnull(sales_forecast,0)) - LAG(sum(isnull(sales_forecast,0))) OVER (PARTITION BY [department name] ORDER BY year(Date)) AS sales_forecastDifference FROM forecasted_table where [department name] like '%hr%' and year(date) = 2023 group by [department name],year(Date) ORDER BY [department name],year(Date)

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
6
Add dataset card