Skip to content
Advertisement

Tag: exists

MySQL customized exists query performance

Because of using Hibernate, I cannot write a JPA query using exists like this (I translated it to pure SQL query): So I have to write an alternative query to check existance of activated accounts. After reading several suggestions on this website, I see a replacement: My question is: Is this bad for performance, is it short circuit query. Means

SQL Server : fastest way to change rows to columns

I’ve got an issue regarding two tables in my database that have the following columns: COMMENT table Composite key made up of (KEY, TYPE, NUMBER) RESULTS table An example of the COMMENT table would be this: For each KEY, there are only 3 different types A,B,C and one TYPE may have up to 0020 in the NUMBER field. These records

SQL – using ‘HAVING’ with ‘EXISTS’ without using ‘GROUP BY’

Using ‘HAVING’ without ‘GROUP BY’ is not allowed: Column ‘products.UnitPrice’ is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause. But when placing the same code under ‘EXISTS’ – no problems: Can you please explain why? Answer well the error is clear in first query UnitPrice is not part

SQL – WHERE NOT EXISTS [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I have a table with employees ID NAME SALARY and I am getting the employee with the most salary with this SQL statement: as I

How to use WHERE EXISTS in a SQL subquery?

I need to find the distinct drinkers who have ordered drinks at a pub on VICTORIA AVE. in March 2020. Here are the tables I am trying to retrieve data from: Here is my SELECT statement so far: Answer The subquery needs to be correlated to the main query in its WHERE clause.

find missing records in corresponding tables

Let’s say I have two temp tables with data that looks like this… Here’s what I am trying to achieve 1) Exclude all records from #TEMP1 and #TEMP2 that have identical match on IdNO, CdId, ApptDate, PROC=Y I’m only interesting in finding these scenarios: 1) Find record from #Temp1 or #Temp2 that matches on all columns, except PROC. So as

Advertisement