Skip to content

Tag: sql-server

Calculate SUM between two dates SQL SERVER

I’m having two tables Calendar ProfileRate I want to calculate SUM. Something like this What I’ve tried: Please help me. Thanks Answer you have to do several steps to solve the problem: combine calendar records with profiles establish which profiles meet the calendar range total the value for each…

Update column value based on the multiple rows

I have a table example: (Col3 is bit datatype) I want to select distinct from the table except for col3 and update col3 value to 0 if col3 values are different. (If all col3 values are same then distinct will return distinct rows). Here I am expecting the output to be: Any help? Edit When col3 values are same…

SQL Transpose for timestamps

I want to ask, how to make output below : from data like this below : with rules the ‘Clock_in’ is the earliest and ‘Clock_out’ is the latest one of the ‘Timestamps’ group by ‘NIP’ Answer If you are using SQL server you can make sure of Cast and group by. output…