Skip to content

Tag: sql

default rows from select query

I have a select query (Oracle database) with group by clause that needs to return 4 rows if all required data exist. It works perfectly. How can I write a select query that returns same 4 rows even if …

How to exclude a specific row from an SQL Count

I need to exclude a certain row from a COUNT in SQL Server. This is what I have: If I remove the last AND GuestStayDetails.GuestId != @GuestId; it gives me the expected COUNT however I must exclude one of the GuestIDs. Any suggestions? Answer It looks like you are looking for overlapping time intervals &#8212…

Can this be done as a SQL VIEW

I have a SQL Server table of Customer’s Events: There can be many EventTypes for the same customer in one day. EventTypes are like 1 – CheckIn 2 – CheckOut 3 – ExamStart 4 – ExamEnd Now I want to select Customers that are currently (today) on premises. That’s Clients who ha…

Calculate sum of duration SQL

I use the following sql to calculate the duration in the first query. CDate(TimeSerial(Val([EndTime])100,Val([EndTime]) Mod 100,0)-TimeSerial(Val([StartTime])100,Val([StartTime]) Mod 100,0))) AS …