I have the following N:N table (which stores the people boardings) in my Oracle Database (it is about an airport): CREATE TABLE boardings( Passport VARCHAR2(8), Day DATE, Flight VARCHAR2(8), …
Tag: subquery
How to get the sum of a subquery that returns sums?
I would like to get the sum of the “sums” in the following case. How can I do that? The following picture represents the table I receive after performing the code below. I’d like to receive only 2 …
Three table join, subquery, or something easier?
I was wondering if someone could help me with this. This is a quick representation of a much more complicated schema. I am looking to get this implementation which is part of a larger stored proc. …
Getting Msg 8623, Level 16, State 1, Line 1 error on a simple select query on one table
How to optimize a simple query that search on one table for IDes that are not a part of a set. I created the following query Be aware that the list includes bit more than 35000 rows. I get the following database error Msg 8623, Level 16, State 1, Line 1 The query processor ran out of internal resources and
Subquery error calculating Free throw statistics
trying to incorporate the query titled “free throws made” as a subquery into the query below it titled “FreeThrowPercByGame” but getting an error. Both work independent of each other in Google Big …
How do I count the customers that made more than a purchase?
I have a table called order that looks like this: I am trying to display: 1.Total count of customers that bought 1 time only (that went to the store in one occasion, it could have been that they bought multiple items but it is only a one time event) 2.Total count customers that bought more than 1 time (that went
SQL: Update every entry with value from another entry that share same column value
I have the following table trn_ReceiptLog I am wondering if it’s possible to update amount of entry #1 to have same as entry #2 IF amount of entry #1 is 0? I have over 5000 of these entries that …
Replace subquery with join for the same table
Can the expected result in this case be accomplished without a subquery ? Maybe using a join ? We have a name say ‘jose’, Expected result is all rows which has same color as jose. Query should run in both MS-SQL and ORACLE. http://sqlfiddle.com/#!18/5f7e3/2 Answer You can get this result with a JOIN, by self-joining on the color field, where
How to Use a Subquery in MySQL in the Where clause that is an argument to an OR operator?
I am trying to filter a table for specific markets by using a subquery. I want to include all null values and exclude the markets that are included in the subquery. This query isn’t filtering out the markets I want to get rid of. And this created a SQL compilation error. When I list the markets I want to exclude
How do you write a sql statement that creates a new column for a date value and then queries it in the WHERE clause
I have written a sql statement as so: SELECT * FROM ( SELECT DATEADD(dd, 60, PaymentDate) AS NewPaymentDate, * FROM MyTable ) x WHERE x.NewPaymentDate >=” & Date() & ” AND …