Skip to content

Tag: sql

Optimising postgresql query

I have this query which is rather slow for my liking : Explain analyse output Is there an index I can put on to speed this up (bearing in mind that the values for the order by will be dynamic)? I was thinking a partial index on where bust,figure,age,hair ethnicity is not null and status = ‘online’…

Update SQL table using C#

I’m trying to update EpisodeId no:117 in the Episode table and it executes successfully but when I check the table it is not updated. int episode Id = 117; Answer There are some issues with your SQL update statement.Look at following for reference to Update Statement in SQL LINK There is also an easier …

join of two queries missing values

I need help joining these two queries. Here’s the first dataset with its query: : and second: : My query produces this result: I need to return as I can’t figure out why my query is leaving out the records with no Inbound data. I believe a right join is correct. It seems like an issue with using t…

Mysql When then and temp variable. Explanation

I have this sql query that I am trying to understand. Can I get a line by line explanation please. I know the first line Initialise variable. Second line gets the minimum value. Answer The variables are enumerating the rows for each occupation separately. You can see this by running the subquery to see the re…

Return a 0 if no rows are found in Microsoft SQL Server

I need your help with this query. My table CSO_EMP_ORG_DPM_VIE has a column with different keys. Column name is EXT_KEY. When I receive the same key number in EXT_KEY, I want the SQL code to count the duplicates using this query: This is working so far, but when it has no duplicate keys (numbers) in the colum…

How to avoid & popup when SQL query contain ‘&’ letter?

I am writing a migration script where I replaced html encoded values by original values like & will get replaced by &. So my SQL query has & letter but when I execute this query it give me popup for every & to replace that character which is as shown below After clicking on OK its giving a…