Skip to content

Instantly share code, notes, and snippets.

@david-mart
Last active June 30, 2019 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-mart/505fdfe38d677ea9d67b788ea2858e37 to your computer and use it in GitHub Desktop.
Save david-mart/505fdfe38d677ea9d67b788ea2858e37 to your computer and use it in GitHub Desktop.
SELECT Domain from bill_items group by Domain;
select
Domain,
Product_Name,
sum(Amount) as total,
DATEPART(Month, Start_Date) as Month,
DATEPART(Year, Start_Date) as Year
from bill_items
group by
Domain,
Product_Name,
DATEPART(Month, Start_Date),
DATEPART(Year, Start_Date)
order by
Domain,
Year,
Month;
select
b.Domain,
a.customer_id
from MSCRMDB.goog.bill_items b
inner join MSCRMDB.crm.agreement_v a on a.customer_domain = b.Domain
group by b.Domain;
select
Domain
from MSCRMDB.goog.bill_items
group by Domain;
select
b.Domain,
a.customer_id
from MSCRMDB.goog.bill_items b
left outer join
MSCRMDB.crm.agreement_v a
on
a.customer_domain = b.Domain
group by a.customer_id, b.Domain;
select customer_id, customer_domain, customer_name from crm.agreement_v where customer_name '%tuilifestyle%' ESCAPE ' ';;
UPDATE
MSCRMDB.goog.bill_items
SET
MSCRMDB.goog.bill_items.customer_id = a.customer_id
FROM
MSCRMDB.goog.bill_items b
INNER JOIN
MSCRMDB.crm.agreement_v a
ON
a.customer_domain = b.Domain;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment