显示当年第一季度销售的产品。 [英] Display the products which are sold in the first quarter of current year.

查看:100
本文介绍了显示当年第一季度销售的产品。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今年第一季度没有收到



我尝试了什么:



i am not getting the first quarter for current year

What I have tried:

select p_name 
from product_table p join order_table o on p.p_id=o.p_id
where quarter(order_date)=1;

推荐答案

我们没有任何访问权限数据库,我们不知道它包含哪些数据,或者你得到了什么 - 但QUARTER将返回本季度的所有日期,无论年份如何。

所以如果你想要仅限本年度,您需要检查列的年份DATEPART与CURDATE年份。
We don't have any access to your DB, and we don't have any idea what data it contains, or what your do get - but QUARTER will return all dates that are in the quarter, regardless of year.
So if you want the Current year only, you need to check the year DATEPART of your column against the year of CURDATE.


根据OriginalGriff指令,请检查:



Accordingly to OriginalGriff instruction, check this:

select p_name, quarter(order_date) AS qrt
from product_table p join order_table o on p.p_id=o.p_id
where quarter(order_date)=1 AND year(order_date) = 2019; --or year(curdate())


这篇关于显示当年第一季度销售的产品。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆