我试图在我的其中一个视图中查找日期数据类型列的日期值范围。
我已经搜索了许多oracle论坛,以寻找类似的错误并且没有运气。
EPAServiceReport视图的列:
{
"Trading name": "ABC Studios",
"Type": [
"Subsidiary",
"Limited liability company"
],
"Industry": "Television production",
"Predecessor": "Touchstone Television",
"Founded": "March\u00a021, 1985; 33 years ago(1985-03-21)",
"Headquarters": "Burbank, California,U.S.",
"Area served": "Worldwide",
"Key people": "Patrick Moran (President)",
"Parent": [
"ABC Entertainment Group",
"(Disney\u2013ABC Television Group)"
],
"Website": "abcstudios.go.com"
}
SQL:
EPASERVICEREPORT_KEY NUMBER(10)
EQUIPMENT_KEY NUMBER(10)
STARIDNO VARCHAR2(60)
WORKORDERNUMBER NVARCHAR2(50)
REPORT_ID NVARCHAR2(50)
CREATEDDATE DATE
结果:
SELECT DISTINCT createddate
FROM epaservicereport
ORDER BY createddate
我希望每个值只能看到1行,即“ distinct”,但是从视图中返回的每一行都有很多重复的值。
答案 0 :(得分:7)
您的日期列也有时间。因此,尽管显示相同,但实际上一天中的时间有所不同。
您可以使用此方法仅获取不同日期:
SELECT DISTINCT TRUNC(createddate)
FROM epaservicereport
ORDER BY 1; --TRUNC(createddate)
答案 1 :(得分:0)
您还可以使用此:
SQL Server:
select distinct CONVERT(varchar(12),createddate,105)
FROM epaservicereport
ORDER BY 1;
有关演员表的更多信息,请点击此处转换
Oracle:
select distinct TO_CHAR(createddate,'YYYY-MM-DD')
FROM epaservicereport
ORDER BY 1;