Created
October 12, 2016 16:33
-
-
Save bsullins/e2bc321d5f50400a00f2c9f4162055b5 to your computer and use it in GitHub Desktop.
I receive the error when trying to add a column to the list of the last select just before the count() aggregate
This file contains 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
-- checkout client data | |
select * | |
from clients; | |
-- how many rows do we have? | |
-- 35,749 | |
select count(1) | |
from sales_all_years | |
-- inner join from sales | |
-- 35,749 | |
select count(1) | |
from sales_all_years s | |
join clients c on s.companyname = c.name | |
-- Add details about clients for a more comprehensive answer | |
select | |
c.marketcaplabel, | |
c.marketcapamount, | |
c.name, | |
c.ipoyear, | |
c.symbol, | |
count(distinct s.orderid) OrderCount, | |
sum(s.saleamount) as TotalSales | |
from sales_all_years s | |
join clients c on s.companyname = c.name | |
group by | |
c.marketcaplabel, | |
c.marketcapamount, | |
c.name, | |
c.ipoyear, | |
c.symbol | |
order by | |
c.marketcapamount desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment