注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
SQL
bookstore
authors/books/transactions/customers四个表
author_id/book_id/customer_id 🔗
Table "books" Table "authors"
+----------------------+---------------+ +-----------------+---------------+
| Column | Type | | Column | Type |
+----------------------+---------------+ +-----------------+---------------+
+->| book_id | INT (KEY) | +->| author_id | INT (KEY) |
| | title | VARCHAR | | | first_name | VARCHAR |
| | author_id | INT >--------|-+ | last_name | VARCHAR |
| | publication_date | DATE | | birthday | DATE |
| | category | VARCHAR | | website_url | VARCHAR |
| _1">找customer who purchase from same author with at least 2 different genres 的交易额
(2) Find customers who purchased books, from the same author, belonging to at least 2 categories. Show the top 3 customers ordered by their total spending on these books.
Sales date/ regitster date- Percentage of customers that registration date is their first sales date
First Purchase Date / Last Purchase Date
6. Find the total books of customers first purchase date and last purchase date -- First purchase date is not the last purchase date, and having at least 3 books
Unique Books- For each customer, find the total number of books and total number of unique books they purchased
Consecutive months- Find top 2 months with unique customers who made purchases this month and the previous month
Interesting Category
9.What percentage of customer have bought at least 1 book not in their interested category?
10 Find author who wrote more than 5 books, order by number of books written from smallest to largest
求加米 |