Sample Header Ad - 728x90

How to write a query from one table with dynamic row and column headings

0 votes
0 answers
25 views
Apologies if this is a basic question, but my google isn't googling, and SQL is not my strongest point. I'm trying to create a table output in SQL where the headings and rows are dynamic. I'm trying to show an output that shows if users signed in on a certain date.
For example, lets look at this SQL table called 'signins' where all the records are kept. | EmployeeName | SignInDate | | -----|----- | |Name1 | 15/05/2025| |Name2 | 15/05/2025| |Name1 | 16/05/2025| |Name2 | 17/05/2025| and i'm trying to output something like this: | | 15/05/2025 | 16/05/2025 | 17/05/2025 | | ------|------------|------------|----------- | |Name1 | T | T | | |Name2 | T | | T | The dates and names could be different and may not be sequential, and i'm not worried at this stage if it's a letter T or something else. I know how to group by date, and i know how to group by name, it's the combining it together and getting this output that i am struggling with. The date column is a date type. I use this to group by: SELECT SignInDate AS SignInDates FROM Signins GROUP BY SignInDate SELECT EmployeeName FROM Signins GROUP BY EmployeeName And this is working for me to be able to grab all the unique dates and names as two separate outputs Can someone point me in the right general direction please to get me started. I think once I have the basics, I'll be able to expand it further to what I need. Thanks
Asked by TonyC (1 rep)
Sep 18, 2025, 02:24 PM
Last activity: Sep 18, 2025, 02:25 PM