Morning all,
I have been trying to get my head around how to achieve this. I have a 2 tables, 1 that stores documents with date added the second stores when users open the documents.
CREATE TABLE [dbo].[Policys](
[PP_ID] [int] NOT NULL,
--[PP_Document] [image] NOT NULL, REMOVED THIS LINE FOR TESTING, IT STORES THE PHYSICAL DOCUMENT.
[PP_DocName] [nvarchar](100) NOT NULL,
[PP_DateAdded] [datetime2](3) NOT NULL
);
INSERT INTO Policys (PP_ID, PP_DocName, PP_DateAdded)
VALUES
('1000', 'Test Doc 1', '2023-02-01'),
('1001', 'Test Doc 2', '2023-02-03'),
('1002', 'Test Doc 3', '2023-02-05');
CREATE TABLE [dbo].[Users_PolicyRead](
[UPPR_ID] [int] IDENTITY(1000,1) NOT NULL,
[UPPR_Username] [nvarchar](20) NOT NULL,
[UPPR_PPID] [int] NOT NULL,
[UPPR_DateRead] [datetime2](3) NOT NULL
);
INSERT INTO Users_PolicyRead (UPPR_Username, UPPR_PPID, UPPR_DateRead)
VALUES
('John', '1000', '2023-02-15'),
('John', '1001', '2023-02-15'),
('Fran', '1000', '2023-02-20'),
('Bob', '1002', '2023-02-21');
So in the expample above John read Test Doc 1 & Test Doc 2 on 15.02.23, Fran read Test Doc 1 on 20.02.23 & Bob read Test Doc 3 on 21.02.23.
What i'm trying to output is basically a report of who read, or hasn't read the documents. Something like this perhaps:
Document John Fran Bob
-----------------------------------------------------------------------------------
Test Doc 1 15/02/23 20/02/23 Not Read
Test Doc 2 15/02/23 Not Read Not Read
Test Doc 3 Not Read Not Read 21/02/23
Or if you have any better ideas how to duisplay the data....??
Any help / pointer greatly apreciated....
Many thanks
Dave