1
我想构建一个允许用户自定义报表的报表系统,并且每个用户都可以在数据网格上创建一个自定义报表。从SQL生成覆盖默认值的报表设置
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的。如果用户具有与user_id = null报告相同的报告名称,则仅返回他们的报告。
这里是我想返回的数据集: USER_ID =用户1
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 =用户3
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帮助我需要?如果这样做最好,我愿意修改表格结构。
问题的第二部分,即没有处理的是,User3和User null的reportname ='Default'的记录,如果存在,我只想要User3的报告。 – Chris 2011-05-02 17:29:19
我更新了SQL,我认为现在应该考虑到这一点。 – 2011-05-02 19:46:25