如何对我的问题进行Sql查询 [英] How to make Sql query for my Problem

查看:73
本文介绍了如何对我的问题进行Sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在asp.net应用程序中工作.在其中我需要显示三个表中的记录.
以下是我的桌子

表1:员工
列名称:ID,名称,EmailID

表2:项目
列名称:ID,日期,EmpID,ProjectName

table3:详细信息
列名称:ID,日期,EmpID,SpentTime,Desc

现在我的要求是我想使用Join
跟随三个表中的列
日期,EmpID,项目名称,总和(花费时间)

在这些表中,项目表中的单个日期可能存在多个记录.当我检索一个月的记录时,我无法获得带有时间总和的记录,那么它没有返回单个日期时间的总和,而是返回了整个蛾类的时间总和.

因此,请给我可以帮助我的SQL查询.

Hello Every One,

I am working in asp.net application. In which I have a requirement to show records from three tables.
following are my tables

table1: employee
column names: ID, Name, EmailID

table2: project
column names: ID, Date, EmpID, ProjectName

table3: Detail
column names: ID, Date, EmpID, SpentTime, Desc

Now my requirement is that i want following columns from three table using joining

Date, EmpID, ProjectName, Sum(SpentTime)

In these tables for a single date in project table multiple records may be exists. I am not able to getting the records with sum of time when i am retrieving records for a month then it is not returning the sum of single date time instead it returns the sum of time for a full moth.

so please give me SQL query which can help me.

推荐答案

尝试一下..
Try this ..
SELECT SUM(SpentTime - CAST('0:0:0' as TIME))
  FROM YourTableName


这篇关于如何对我的问题进行Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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