I’m using SQL Management Studio 2012. I’m getting a ‘Divide by zero error encountered’ error. I’m aware this requires the use of NULLIF but I’m unsure how to use it in my query. This is my query I’ve actually asked this question before which some kind person answered excellently but that was without the OVER() and SUM aggregate function, I’m
Tag: ssms
Getting Error While Setting The data to Sql Db, Saying Cannot set the Value of Created at with Null
I am Creating a table in SSMS with the Columns required for the Table and also with the Entitydata mandatory fields Like Id, CreatedAt, UpdatedAt, Version, Deleted. And while setting the data through …
Get the max date time in a table with multiple entries for each date
I have a table that has Location | IsBroken | Date AZ 1 2019-01-01 12:00 CA 0 2019-01-01 12:00 NY 1 2019-01-01 12:00 AZ 1 2019-01-…
Select only rows that satisfy 60% of the where clause – SQL Server
I am facing a challenge in SQL. I have the following query: SELECT * FROM Books WHERE Categories IN (‘Fiction’, ‘art’) OR Language IN (‘en’, ‘de’) OR Country = ‘DE’ I need to look at …
How do I display two different sums of the same price with different parameters?
I need to get the SUM of 2 different Totals. One is just the Total and the second one is the Total that only includes products that are sold for less than $25. SELECT SUM(Price) AS Total FROM Sales (…
Dynamically Updating Columns with new Data
I am handling an SQL table with over 10K+ Values, essentially it controls updating the status of a production station over the day. Currently the SQL server will report a new message at the current …
Query returning data outside the scope of the WHERE condition
I’m trying to retrieve summarized data from the table depending on DateTime and state. The problem is I need multiple state values ex. ‘where 1 or 2 or 3’ SELECT SUM(ticketTotalAmount) FROM tickets …
Using ISNULL or COALESCE on date column
I’ve got a date column where some rows have got NULL values. I would like to use ISNULL or something like that to substitute those values with something like ‘N/A’, however, when I try to use ISNULL, I get an error due to two different data types. If I try to convert my Date column to VARCHAR in order to
SQL Statement // between with datetime
I have following query: select s.ScreenID, s.ScreenName, ps.ScheduleDate from Screens s left join PerformanceSchedules ps on ps.ScreenID = s.ScreenID where s.TheatreID = 2 and ((ps.ScheduleDate not …
How can I retrieve first second and third word of a String in SQL?
I need a query which would extract the first second and third word of a string. I have approximately 5 words in each row and I need only the first three words out of 5 in the same row (1 row). …