-1

i have this data

from the above data i want to get the date wise attendance for respective student expecting for this kind of output

can anyone please help what sql query should i use

  • 2
    You better give sample data in text (table format), unless you want us to key in manually :) – Hana Jun 16 '22 at 03:27
  • This might be helpful for you, please check https://stackoverflow.com/questions/18116020/sql-server-2008-vertical-data-to-horizontal – Harshad Nannaware Jun 16 '22 at 06:50

1 Answers1

0

You could try using a CROSS APPLY. I have an example below but it is hard to test since I don't have access to the data. Hopefully, this will at least get you in the right direction. try this:

SELECT 
ca.name, 
ca.attenance_date, 
CASE WHEN ca.present = 1 THEN 'Present' AS Present, 
CASE WHEN ca.present = 0 THEN 'N/A' AS Not_Present,
FROM Table CROSS APPLY Values (name, attenance_date)) ca
(name, attenance_date);
Desert Eagle
  • 191
  • 14