KCL Software Solutions

SQL to Find Records with Feedback

Feedback SQL - Community Information

Records with Feedback of any kind:

EXISTS(SELECT * FROM GBL_FeedbackEntry WHERE NUM=bt.NUM)

Records with Feedback submitted by the public:

EXISTS(SELECT * FROM GBL_FeedbackEntry WHERE NUM=bt.NUM
AND User_ID IS NULL)

Records with Feedback submitted by the staff:

EXISTS(SELECT * FROM GBL_FeedbackEntry WHERE NUM=bt.NUM
AND User_ID IS NOT NULL)

Records with Feedback submitted by a specific staff member (UserName is case sensitive):

EXISTS(SELECT * FROM GBL_FeedbackEntry fbe
INNER JOIN GBL_Users u ON fbe.User_ID=u.User_ID
AND UserName='JaneDoe'
WHERE fbe.NUM=bt.NUM)

Records with Feedback submitted today:

EXISTS(SELECT * FROM GBL_FeedbackEntry WHERE NUM=bt.NUM
AND SUBMIT_DATE > GETDATE())

Records with Feedback submitted between two dates:

EXISTS(SELECT * FROM GBL_FeedbackEntry WHERE NUM=bt.NUM
AND SUBMIT_DATE BETWEEN '1 Aug 2015' AND '1 Sep 2015')

Feedback SQL - Volunteer Opportunities

Records with Feedback of any kind:

EXISTS(SELECT * FROM VOL_Feedback WHERE VNUM=vo.VNUM)

Records with Feedback submitted by the public:

EXISTS(SELECT * FROM VOL_Feedback WHERE VNUM=vo.VNUM
AND User_ID IS NULL)

Records with Feedback submitted by the staff:

EXISTS(SELECT * FROM VOL_Feedback WHERE VNUM=vo.VNUM
AND User_ID IS NOT NULL)

Records with Feedback submitted by a specific staff member (UserName is case sensitive):

EXISTS(SELECT * FROM VOL_Feedback fbe
INNER JOIN GBL_Users u ON fbe.User_ID=u.User_ID
AND UserName='JaneDoe'
WHERE fbe.VNUM=vo.VNUM)

Records with Feedback submitted today:

EXISTS(SELECT * FROM VOL_Feedback WHERE VNUM=vo.VNUM
AND SUBMIT_DATE > GETDATE())

Records with Feedback submitted between two dates:

EXISTS(SELECT * FROM VOL_Feedback WHERE VNUM=vo.VNUM
AND SUBMIT_DATE BETWEEN '1 Aug 2015' AND '1 Sep 2015')

Did you find this article helpful?