【发布时间】:2011-05-03 01:41:13
【问题描述】:
我正在尝试构建一个允许用户自定义报告的报告系统,并且每个用户都可以在数据网格之上创建自定义报告。
ID GRIDID USER_ID REPORTNAME REPORTPAYLOAD CREATED
--- -------------------- ------- ----------- ------------- ------------------
4 CompleteReportView1 User1 Completed (CLOB) 4/18/2011 8:40:05
6 CompleteReportView1 User1 All (CLOB) 4/18/2011 8:40:48
10 CompleteReportView1 Completed (CLOB) 4/18/2011 8:40:05
12 CompleteReportView1 All (CLOB) 4/18/2011 8:40:48
16 CompleteReportView1 Default (CLOB) 4/18/2011 9:53:38
18 CompleteReportView1 User2 Completed (CLOB) 4/18/2011 8:40:05
20 CompleteReportView1 User2 All (CLOB) 4/18/2011 8:40:48
33 CompleteReportView1 User3 Default (CLOB) 4/18/2011 9:53:38
我希望特定用户的报告列表包括他们设置的所有报告,以及 User_Id 为 null 的报告。如果用户的报告名称与 user_id=null 报告相同,则只返回他们的报告。
这是我想要返回的数据集: User_Id = User1
ID GRIDID USER_ID REPORTNAME REPORTPAYLOAD CREATED
--- -------------------- ------- ----------- ------------- ------------------
4 CompleteReportView1 User1 Completed (CLOB) 4/18/2011 8:40:05
6 CompleteReportView1 User1 All (CLOB) 4/18/2011 8:40:48
16 CompleteReportView1 Default (CLOB) 4/18/2011 9:53:38
User_Id = 用户 2
ID GRIDID USER_ID REPORTNAME REPORTPAYLOAD CREATED
--- -------------------- ------- ----------- ------------- ------------------
16 CompleteReportView1 Default (CLOB) 4/18/2011 9:53:38
18 CompleteReportView1 User2 Completed (CLOB) 4/18/2011 8:40:05
20 CompleteReportView1 User2 All (CLOB) 4/18/2011 8:40:48
User_Id = User3
ID GRIDID USER_ID REPORTNAME REPORTPAYLOAD CREATED
--- -------------------- ------- ----------- ------------- ------------------
10 CompleteReportView1 Completed (CLOB) 4/18/2011 8:40:05
12 CompleteReportView1 All (CLOB) 4/18/2011 8:40:48
33 CompleteReportView1 User3 Default (CLOB) 4/18/2011 9:53:38
有人可以帮助我需要的 sql 吗?如果这样做最有意义,我愿意修改表结构。
【问题讨论】: