查询以获取“ prix_total” SQLITE的每月3

发布于 2025-01-31 17:07:18 字数 470 浏览 2 评论 0原文

我有一个具有以下属性的表,“ id_commande,id_client,id_agent,d_commande,heure_commande,prix_total”。 D_Commande代表销售日期 prix_total表示销售的价格。

我尝试创建一个查询时每月获得“ prix_total”。我挣扎。 请注意,我尝试了此查询,但我没有得到正确的结果:

SELECT sum(prix_total)
FROM commande
GROUP BY (
     SELECT strftime('%y','D_commande')
)

I have a table with the following attributes, "id_commande, id_client, id_agent, D_commande, Heure_commande, prix_total".
D_commande represents DATE OF SALE
prix_total represents the price of a sale.

enter image description here

when I tried to create a Query to Get the "prix_total" per month. I struggled.
notice that I tried this query but I don't get the correct result:

SELECT sum(prix_total)
FROM commande
GROUP BY (
     SELECT strftime('%y','D_commande')
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月流歌 2025-02-07 17:07:18

您可以使用

SELECT strftime('%Y-%m',D_commande) AS month, 
       SUM(prix_total) AS prix_total
  FROM commande 
 GROUP BY strftime('%Y-%m',D_commande)
 ORDER BY month

几个月来将结果划分

You can use

SELECT strftime('%Y-%m',D_commande) AS month, 
       SUM(prix_total) AS prix_total
  FROM commande 
 GROUP BY strftime('%Y-%m',D_commande)
 ORDER BY month

in order to get the result partitioned by months

酒几许 2025-02-07 17:07:18
SELECT sum(prix_total)
FROM commande
GROUP BY strftime('%Y',D_commande) 
       , strftime('%m',D_commande) 

ORDER BY strftime('%Y',D_commande) 
       , strftime('%m',D_commande) 
   
SELECT sum(prix_total)
FROM commande
GROUP BY strftime('%Y',D_commande) 
       , strftime('%m',D_commande) 

Here is a demo

And also you can order by year and month:

ORDER BY strftime('%Y',D_commande) 
       , strftime('%m',D_commande) 
   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文