【问题标题】:Count product selled in a day for each type of product计算每种产品在一天内销售的产品
【发布时间】:2021-08-16 15:07:57
【问题描述】:

我的查询有问题。 想象一下,我有 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>
)

【问题讨论】:

  • 请移除 android-jetpack-compose 标签

标签: android kotlin android-room


【解决方案1】:

数据库的设计应能满足您的需求。 如果您不想添加仅包含日期的额外列,您可以计算今天 00:00 的时间戳并进行查询“Select orderList where timestamp > $todayTimestamp”

另外,时间戳不应该是字符串。

【讨论】:

    猜你喜欢
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多