SELECT
root_proj.r_proj AS root_project_name ,
great_proj.g_proj AS great_project_name ,
parent_proj.p_proj AS parent_project_name ,
proj.project AS project_name,
task.task_name AS task_name,
root_proj.Time AS root_time,
great_proj.Time AS great_time ,
parent_proj.Time AS parent_time ,
proj.Time AS project_time,
task.task_time AS task_time ,
proj.Name AS user_name
FROM (
SELECT per.surname AS Name ,
p.name AS project ,
sec_to_time(sum(wi.wEnd-wi.wBegin)) AS Time ,
parent.id AS p_parent_id ,
p.id AS id
FROM T4U_WORKITEMS wi
INNER JOIN T4U_DAYINFOS di ON ( wi.dayinfo_id = di.id )
INNER JOIN T4U_TASKS t ON ( wi.task_id = t.id )
INNER JOIN T4U_PROJECTS p ON ( wi.project_id = p.id )
INNER JOIN T4U_PERSONS per ON ( di.person_id = per.id )
INNER JOIN T4U_PROJECTS parent ON ( ifnull(p.parent_id , p.id) = parent.id )
WHERE
di.daydate = '2009-03-09'
AND per.surName LIKE "eric%"
GROUP BY p.id ) AS proj
LEFT JOIN (
SELECT per.surname AS Name ,
parent.name AS p_proj ,
parent.parent_id AS parent_parent_id ,
parent.id AS p_id ,
sec_to_time(sum(wi.wEnd-wi.wBegin)) AS Time
FROM T4U_WORKITEMS wi
INNER JOIN T4U_DAYINFOS di ON ( wi.dayinfo_id = di.id )
INNER JOIN T4U_TASKS t ON ( wi.task_id = t.id )
INNER JOIN T4U_PROJECTS p ON ( wi.project_id = p.id )
INNER JOIN T4U_PERSONS per ON ( di.person_id = per.id )
INNER JOIN T4U_PROJECTS parent ON ( ifnull(p.parent_id , p.id) = parent.id )
WHERE
di.daydate = '2009-03-09'
AND per.surName LIKE "eric%"
GROUP BY parent.id ) AS parent_proj
ON proj.p_parent_id = parent_proj.p_id
LEFT JOIN
(SELECT per.surname AS Name ,
great.name AS g_proj ,
great.parent_id AS great_parent_id ,
great.id AS g_id ,
sec_to_time(sum(wi.wEnd-wi.wBegin)) AS Time
FROM T4U_WORKITEMS wi
INNER JOIN T4U_DAYINFOS di ON ( wi.dayinfo_id = di.id )
INNER JOIN T4U_TASKS t ON ( wi.task_id = t.id )
INNER JOIN T4U_PROJECTS p ON ( wi.project_id = p.id )
INNER JOIN T4U_PERSONS per ON ( di.person_id = per.id )
INNER JOIN T4U_PROJECTS parent ON ( ifnull(p.parent_id , p.id) = parent.id )
INNER JOIN T4U_PROJECTS great ON ( ifnull(parent.parent_id ,parent.id) = great.id )
WHERE
di.daydate = '2009-03-09'
AND per.surName LIKE "eric%"
GROUP BY great.id ) AS great_proj
ON parent_proj.parent_parent_id = great_proj.g_id
LEFT JOIN
(SELECT per.surname AS Name ,
root.name AS r_proj ,
root.parent_id AS root_parent_id ,
root.id AS r_id ,
sec_to_time(sum(wi.wEnd-wi.wBegin)) AS Time
FROM T4U_WORKITEMS wi
INNER JOIN T4U_DAYINFOS di ON ( wi.dayinfo_id = di.id )
INNER JOIN T4U_TASKS t ON ( wi.task_id = t.id )
INNER JOIN T4U_PROJECTS p ON ( wi.project_id = p.id )
INNER JOIN T4U_PERSONS per ON ( di.person_id = per.id )
INNER JOIN T4U_PROJECTS parent ON ( ifnull(p.parent_id , p.id) = parent.id )
INNER JOIN T4U_PROJECTS great ON ( ifnull(parent.parent_id ,parent.id)= great.id )
INNER JOIN T4U_PROJECTS root ON ( ifnull(great.parent_id ,great.id) = root.id )
WHERE
di.daydate = '2009-03-09'
AND per.surName LIKE "eric%"
GROUP BY root.id ) AS root_proj
ON great_proj.great_parent_id = root_proj.r_id
RIGHT JOIN (
SELECT per.surname AS Name ,
t.name AS task_name ,
p.id AS project_id ,
sec_to_time(sum(wi.wEnd-wi.wBegin)) AS task_time
FROM T4U_WORKITEMS wi
INNER JOIN T4U_DAYINFOS di ON ( wi.dayinfo_id = di.id )
INNER JOIN T4U_TASKS t ON ( wi.task_id = t.id )
INNER JOIN T4U_PROJECTS p ON ( wi.project_id = p.id )
INNER JOIN T4U_PERSONS per ON ( di.person_id = per.id )
WHERE
di.daydate = '2009-03-09'
AND per.surName LIKE "eric%"
GROUP BY t.id ,p.id ) AS task
ON proj.id = task.project_id
分享到:
相关推荐
根据提供的文件信息,我们可以深入探讨如何在SAS环境中利用Proc SQL进行数据处理和分析。这份文档似乎是一本关于如何在SAS中运用SQL语言的指南书籍。下面将详细阐述各章节涉及的重要知识点。 ### 一、简介 #### ...
2. **控制结构**:PL/SQL的流程控制是其强大之处,书中详细讨论了循环(WHILE、FOR)、条件判断(IF-THEN-ELSIF、CASE)以及异常处理(BEGIN-EXCEPTION-END)等结构,使读者能够编写出逻辑清晰的代码。 3. **游标**...
2. 在C#代码中添加日志记录,输出查询的SQL语句和执行前后的变量状态,以帮助定位问题。 3. 使用 `Try...Catch` 块捕获可能出现的异常,以便于发现潜在的错误信息。 4. 如果可能,尝试使用 `SqlCommand....
2. **过程和函数**:了解如何定义和调用存储过程和函数,这些是PL/SQL中的核心组件,用于封装和重用代码。 3. **游标**:学习如何使用游标来遍历查询结果集,这是处理单行或逐行数据的常见方法。 4. **记录和表...
《PL.SQL by Example》是一本专注于Oracle数据库PL/SQL编程实践的资源,它提供了一系列的实例脚本,旨在帮助读者深入理解和掌握PL/SQL语言。PL/SQL是Oracle数据库系统中的一个关键组件,用于开发存储过程、触发器、...
Oracle® PL/SQL™ by Example, Third Edition By Benjamin Rosenzweig, Elena Silvestrova Publisher : Prentice Hall PTR Pub Date : September 10, 2003 ISBN : 0-13-117261-1 Pages : 768
《Oracle PL/SQL by Example》是一本专注于Oracle数据库系统中PL/SQL编程语言的经典教程。PL/SQL,全称为Procedural Language/SQL,是Oracle数据库内置的一种过程化编程语言,它结合了SQL的查询能力与面向过程的编程...
【ArcTutor SQL_Example】是一个专门为初学者和专业用户设计的教程,旨在帮助他们理解和掌握如何在GIS(地理信息系统)环境中使用SQL语言操作空间数据库。这个教程是基于ArcGIS平台,由Esri公司开发的ArcTutor系列...
Oracle SQL By Example 4th Edition by Alice Rischert - 5 Star Book Review.pdf
An introduction to SQL for the absolute beginner. Learn how to create and query databases, add and remove data from tables, set constraints, create stored procedures, and more
本书通过实际的实验、示例和项目来讲解你所需的全部PL/SQL技能,它涵盖从基础语法、程序控制到最新的优化和安全增强等方面的知识。读者循序渐进地学习每个关键任务,自己就能掌握当今最有价值的Oracle12c的PL/SQL...
2. **数据库连接**: `DBHelper`类会包含一个用于建立和管理与SQL Server连接的方法。例如,`GetConnection()`方法可能创建并返回一个`SqlConnection`实例,同时处理连接字符串的配置。 3. **事务处理**: 对于复杂的...
"call-SQL-data-example.rar_sql"这个标题暗示我们这里有一个压缩包,其中包含了一个关于如何调用SQL来操作数据库的实例。描述中提到,这个例子涵盖了基本的数据库操作,包括增(Insert)、删(Delete)、查(Select...
英文原版 Start developing applications with Oracle PL/SQL
后端拿到请求参数需要进行sql语句拼接,由于mybatis-generator的example类存在较多问题,对其进行改进: ...2.保证业务代码中不出现sql语句 3.可以生成嵌套的or条件语句 4.实现良好的代码提示不补全
There are a lot of materials mention the hr_main.sql for test, but I can't find it in the $ORACLE_HOME/demo/schema/human_resources/; so enjoy it for you and wish to help U
Oracle PL_SQL by Example,PL_SQL 案例在用jdbcs时可以参考
2) **使用指针进行SQL数据库操作**: 在C++中,使用指针可以提高代码的灵活性和效率。在Qt中,我们可以创建`QSqlDatabase`和`QSqlQuery`的指针,如: ```cpp QSqlDatabase *pDb = new QSqlDatabase(QSqlDatabase::...