1083. Sales Analysis II 难度:简单

1、题目描述

Write an SQL query that reports the buyers who have bought S8 but not iPhone. Note that S8 and iPhone are products present in the Product table.
The query result format is in the following example:
Product table:

product_id product_name unit_price
1 S8 1000
2 G4 800
3 iPhone 1400

Sales table:

seller_id product_id buyer_id sale_date quantity price
1 1 1 2019-01-21 2 2000
1 2 2 2019-02-17 1 800
import os import matplotlib.pyplot as plt class Commodity: def __init__(self, num, name, total, sales, inventory, ds): self.num = num self.name = name self.total = int(total) self.sales = int(sales) self.inventory = int(inventory) self.ds = [int(x) for x in ds] def updatesales(self): """根据ds更新sales和inventory""" self.sales = sum(self.ds) self.inventory = self.total - self.sales def loadcommodities(filename): commodities = [] if not os.path.exists(filename): return commodities with open(filename, 'r', encoding='utf-8') as f: for line in f: line = line.strip() if not line: continue parts = line.split(',') num, name, total, sales, inventory, *ds = parts commodities.append(Commodity(num, name, total, sales, inventory, ds)) return commodities def savecommodities(filename, commodities): with open(filename, 'w', encoding='utf-8') as f: for c in commodities: f.write(f"{c.num},{c.name},{c.total},{c.sales},{c.inventory},{','.join(map(str, c.ds))}\n") def readtextfile(filename): """读取磁盘上的文本文档内容并返回""" try: with open(filename, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print(f"文件 {filename} 未找到。") return None except Exception as e: print(f"读取文件时发生错误:{e}") return None def writetextfile(filename, content): """将内容写入磁盘上的文本文档""" try: with open(filename, 'w', encoding='utf-8') as file: file.write(content) print(f"文件 {filename} 已保存。") except Exception as e: print(f"写入文件时发生错误:{e}") # 其他函数定义... def main(): filename = 'commodities.txt' textfilename = 'notes.txt' commodities = loadcommodities(filename) while True: print("\n商品管理系统") print("1. 添加商品") print("2. 修改商品") print("3.
03-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值