The code: The SSMS output: The output form loads slowly, the rows for the query are over 1000 so I think the cause of the slow load is the number of returned rows? If yes, how do make the load of the datagridview faster? Answer NOTE – this answer relates to the first part of the original question regard…
Tag: sql
How to improve Clustered Index scan to Clustered Index seek?
I have two tables with primary clustered keys by id. Also I have stored procedure The Execution plan shows me a ‘Clustered Index Scan’ that I want to avoid. Is there any way I can convert it to a ‘Clustered Index Seek’? Execution Plan screen <db fiddle> Answer As I mentioned in t…
SQL sort by each hour with different dates
I have a sql table like this How to I sort by each hour to get this: Your help is very much appreciated 😀 Answer Here is a MySQL solution: select DATE_FORMAT(min(time), ‘%h:00’),sum(occ_val) from tbl group by hour(time) See https://www.db-fiddle.com/f/czudbp5zug6HxX4TFV26GT/0
Query Search Algorithm using priority array and ignoring conditions
I am facing this problem at my companies logistics: Given array of mixed values ordered by priority ASC (v1 is more important than v2, … etc) I need to search values in a table t like this: The 3 dots in query are the fixed conditions If I cant find any value from query, perform same query ignoring the …
Timeserial not recognized built in function in MS SQL
I am trying to implement an SQL query that gets records between today’s fixed timing 18:00 and yesterday’s fixed timing 18:00 based on a Date time column that I have in my table. I tried this query But, it’s throwing an error Timeserial is not a recognized built-in function name. Any ideas p…
Select max entries in a range in SQL server
I have a salary column where I have to select between range of 10000 and 20000 and also the top rows of max salary. Column I have: Rows I want to select I can use top n rows but that will apply on to this column. What I want to do is, say if this column has 2 rows that
I am getting “missing keyword” error in oracle sql
I am new to SQL and I am trying to create the table for itinerary items however keep getting the same error message that I am “missing a keyword”. I have tried looking it up for what is wrong however I can not find anything Any solution or if you have any design suggestions to this would be much a…
Remove minutes and seconds and then convert to UTC timezone
I have column with time stamp data like this 2021-12-09 08:01:00.520 I want to remove the minutes and second and then convert the date to UTC timezone in one line. I tried this code I get this result 2021-12-09 08:00:00.000 and I tried this code I get this result 2021-12-09 16:01:00.520 What I expected is 202…
PL/SQL: IF or CASE statement to check two variables in a single row and return a third variable?
I need PL/SQL code to scan a table (tied to page 5 in Apex), see if a row with two variables (a specific ID and a specific number between 1-3) exists, and return a third variable from that row into an Oracle Apex item (this is a dynamic action on page 10) if it does. I can do this with
Filter table to leave out specific rows
I have the table and now I want to list every ProjectName where there is no specified Leader like this: Right now I only know how to filter all ProjectNames with Leaders, but not the way to filter them the other way! Any help is appreciated 🙂 Answer One way to do it is with aggregation and the condition in