android - 统计每种产品在一天内销售的产品
问题描述
我的查询有问题。想象一下,我有 10 个产品(product1、product2、product3),今天(08/16/2021),我正在销售 15 个“product1、2 个 product2 和 5 个 product3。我需要现在每天销售多少个产品,并且每天都能得到它们。
告诉我我的课程是否足够好,以及我可以使用什么查询或代码。
@Entity(tableName = "stock_products")
data class StockProducts (
@PrimaryKey(autoGenerate = false)
val id: String,
@ColumnInfo(name = "timestamp")
val timestamp: String,
@ColumnInfo(name = "productName")
val orderList: List<ProductInfo>
)
解决方案
数据库的设计应满足您的需求。如果您不想添加仅包含日期的额外列,则可以计算今天 00:00 的时间戳并进行查询“Select orderList where timestamp > $todayTimestamp”
此外,时间戳不应该是字符串。
推荐阅读
- python - 用相同数据框中的值填充 NaN 信息
- java - 如何修复 org.eclipse.jgit.api.errors.JGitInternalException:Entry not found by path Exception while doing commit using Egit
- python - 如果条目本身是结构化数组,如何将 numpy 数组中的条目设置为 0 或 None?
- python - 只获取一些标签
使用网站上的 BeautifulSoup
- sql-server - 当 Duration_Hours 是另一个数据库表的 LEFT JOIN 时,如何求和?
- apache-kafka-streams - 我可以在 Kafka 中压缩 KafkaStream 使用的中间主题(状态存储)吗
- python - 即使我使用的是 try 和 except 方法,也无法避免 ElementNotVisibleException
- python - 为什么使用 pandas 和 xlsxwriter 会出现值错误?
- php - PHP exif_read_data():无法打开文件查询
- java - xsd 模式生成的类中的问题