Skip to content

assignment-one sql#1

Open
CarlaKulcsar wants to merge 1 commit into
mainfrom
assignment-one
Open

assignment-one sql#1
CarlaKulcsar wants to merge 1 commit into
mainfrom
assignment-one

Conversation

@CarlaKulcsar

Copy link
Copy Markdown
Owner

No description provided.

@anjali-deshpande-hub anjali-deshpande-hub left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! 29/30

GROUP BY customer.customer_id
HAVING SUM(cost_to_customer_per_qty) > 2000
ORDER BY customer_last_name, customer_first_name;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total_spent should be SUM(quantity * cost_to_customer_per_qty)

The HAVING clause can simply use total_spent > 2000 instead of recalculating.

The result set will give 19 rows instead of just 3.

UNION ALL
SELECT '10', 'Thomas Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal';


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct answer uses INSERT statement:

CREATE TABLE temp.new_vendor AS
SELECT * FROM vendor

INSERT INTO temp.new_vendor
VALUES (10, "Thomass Superfood Store" , "Fresh Focused", "Thomas", "Rosenthal")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants