Skip to content

Tag: sql-server

Insert every other row to a Column

I have this Table with one row Transaction Date the first row is the checkIn and the second one is the Checkout if we organized the result by date asc. I need to pass the second row value to another …

how to take average for Varchar data type

one of my column in my table is of type varchar. which contains hexadecimal values. i need to take average for particular month . the below is my query. please help me how to change the code to achieve it. Thanks in advance Answer You can use CAST to DateTime CAST For example The filed should be a DateTime st…

Getting wrong output in pivot query

Attendance Table Sample Data – Student Table Sample Data – StudentSubject Table Sample Data – Subject Table Sample Data – Output – Wrong output is displaying with parameters – As 2,1,0 and NA,NA,1 should be displayed instead 2,1,1 and 2,1,1 is displaying. Couldn’t poi…