I am using SQL Server. I created two views to get a few results and then made them into one select to use on the inner join. I’m sure there’s an easier way to do this. I couldn’t think of anything else at the moment. Please teach me! My results What I’m looking for Thank you for your t…
How distinct works in sql?
I tried to understand how the distinct (and therefore distinct count) work. I have a data with: While within 1 SessionID there is 1 User_solici. However, there could be multiple SessionID for the same User_solici. For User_solici of “a”, I have Session = 1, 55 and null. I want to find distinct Ses…
Multiple joins on same table
I’m trying to achieve a query which seems simple but I can’t make it work correctly. Here’s my database tables structures: Here’s what i want to achieve: Mutliple members can register to an activity. Then, i group the registrations by tandems. I want a view with all the tandems listed …
How to identify best Max_bucket and Seed_value for Oracle ORA_Hash function?
I am new to Oracle Hash function. I know that this function is for encryption purpose. It is actually convert a very large paragraph into one single hash value. The Ora_hash function have three different parameters: Expression Max_bucket Seed_value For the Max_bucket and seed value, the document says I can sp…
PostgreSQL: exclude complete jsonb array if one element fails the WHERE clause
Assume a table json_table with columns id (int), data (jsonb). A sample jsonb value would be When I use an SQL statement like the following: … the two array elements are unnested and the one that qualifies the WHERE clause is still returned. This makes sense since each array element is considered indivi…
Deadlock Exception during select
I am trying to solve a deadlock exception in a spring-boot application running with JPA. I get the following error in the spring boot log. 24 Feb 2020 10:04:11.382 [WARN ] {pool-10-thread-4} [org….
Is there a way I can get output of count values in MySql?
I am dealing with getting the output of some common values. My database is quite big so I am just giving a dummy database here for understanding purposes. Here is the table I have: I have to extract only those variables that have the given common room numbers alotted. This is the table for the required data: …
How can I run this SELECT query?
I’m working on a Messaging feature for an application, and I have a the following tables in MSSQL, along with a User table (not listed): I want to query the ThreadParticipant table for whether or not a thread exists containing only a given set of user ids, let’s say users 1,3,5,7. Each Thread cont…
Show the names of customers that have accounts SQL Query Oracle 10G
Q1 Show the names of customers that have accounts Q2 Show the customer names with the names of the employees they deal with** Answer Q1 is a simple lookup of the cust_id in junction table has: This phrases as: select the customers that have at least one entry in the has table. When it comes to Q2: your data s…
SQL Date Range Specification, Explicit vs BETWEEN()
My understanding of SQL is that is the same as But I’m getting completely different ResultSets when the only difference in the queries is the date range specification. The correct dates are being returned but the data is different. This is happening in both Teradata and HANA. Am I missing something? EDI…