如何在PostgresSQL中使用select Query? [英] How to use select Query in PostgresSQL?
问题描述
亲爱的所有人,
我使用的是Asp.net C#和Postgresql。我需要记录超过0.5的持续时间。我正在使用以下查询。
SELECTEmployeeID,EmployeeName,日期(StartTime),sum(to_number(Duration,'9999.99) '))asDurFROMEmployee_TimeSheetWHERE日期(StartTime)日期('1/1/2016 12:00:00 AM')和日期('1/31/2016 12:00:00 AM ')
group byEmployeeID,EmployeeName,date(StartTime);
获取以下记录类型。< br $>
Dear All,
I am using Asp.net C# and Postgresql. I need to get record of more than 0.5 of duration.I am using following Query.
SELECT "EmployeeID", "EmployeeName",date("StartTime") ,sum(to_number("Duration",'9999.99')) as "Dur" FROM "Employee_TimeSheet" WHERE date("StartTime") between date('1/1/2016 12:00:00 AM') and date('1/31/2016 12:00:00 AM')
group by "EmployeeID", "EmployeeName",date("StartTime");
Get Following type of Records.
"Name"; "Date" ;"Duration"
"Thirugnana sambantham_V";"2016-01-30";0
"Beeresh_H E";"2016-01-29";0.81
"Prabahar_A";"2016-01-29";0.46
"Ramakrishnan_N";"2016-01-28";0
"Saravanakumar_S";"2016-01-30";1.61
"Madhu_K E";"2016-01-29";2.5
"Marimuthu_V";"2016-01-29";0.99
"Thirugnana sambantham_V";"2016-01-27";0.74
我只需要超过0.5的持续时间任何一个修改我的查询以满足需要。
谢谢提前。
I need only more then 0.5 of duration any one modified my query for that need.
Thanks Advance.
推荐答案
我有两种方法可以想到,但不清楚你是否想要总持续时间到是> 0.5或选择持续时间的单个记录> 0.5(并查看那些看你代码的人)
在第一个例子中,我会看看这个PostgreSQL:文档:8.1:聚合函数 [ ^ ],在第二个,你肯定可以在查询中添加'和duration ...'子句
There's two ways I can think of, but Its not clear if you want the total duration to be > 0.5 or select individual records of duration > 0.5 (and sum those looking at your code)
In the first instance, I would look at this PostgreSQL: Documentation: 8.1: Aggregate Functions[^], in the second, well surely you can add the 'and duration ... ' clause to your query
这篇关于如何在PostgresSQL中使用select Query?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!