This is my table definition: And this is my query + plan: So the index is used, but there is still a scan and a b-tree involved in the order by. I tried getting rid of them by adding more indexes, but I don’t get it working. Any ideas of an index which gets rid of the scan? Answer Your
Tag: union
SQL Query to fetch the customers registered in the DB without email address(CS can have phonenumber and email in the same field but duplicating)
I need help with writing this query please , in the Database – the customer is registered twice , one row with the email address in the VALUE field and the other row with phone number in the SAME VALUE field . I want to fetch customer who DO NOT HAVE email address in the VALUE FIELD . For example
While loop function union function end
I want to loop the code shown below. I would like to use the [getpublicholidays] function for a variable number of years and merge them (union). Unfortunately I don’t know how to use the function in a loop with union. Can someone help? Answer If you are looping for X years, each time you loop to a new year, you
How to join one column multiple times to many columns? – SQL
I have two tables like: I want an output like: I think this will require JOIN and UNION ALL, but I can’t figure out how exactly to put everything together. I’m confused because we’ll need to join multiple times per row. Would appreciate any help, thanks Answer You can do: However, I would say the cardinalities of those relationships look
FULL OUTER JOIN (or UNION) on 2 tables
I’m facing a SQL request issue. I’m not a SQL expert and I would like to understand my mistakes. My use case is to get all records of the first table + records of the second table that are not present in the first table. I’ve got 2 tables like this : First table “T-Finance par jalon ZOHO” (with 20
Oracle developer. ORA-01722 Invalid Number when using UNION
I have this problem: I have two tables: Table A and Table B, with the same column called PK_COLUMN that in both tables are numeric(8, 0). I want to make this union: And I got the next error code: ORA-01722 Invalid number. The problem is that when I execute the both parts of the union separately they work perfectly! Answer
Filter a Dataframe using a subset of it and two specific fields in spark/scala [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 10 months ago. Improve this question I have an Scala/Spark question. I’m using Spark 2.1.1. I have a Dataframe
Is there a more efficient way to append multiple columns from the same table?
I’d like to return multiple values from the same record, with different columns of the same type appended under one another. I could do multiple joins, but that seems very inefficient because of the multiple table scans. Returns: VisID Vis Home HomeID arenn001 Nolan Arenado Colin Moran morac001 badeh001 Harrison Bader Anthony Alford alfoa002 carld002 Dylan Carlson Yoshi Tsutsugo tsuty001
Concatenate 2 rows into one in SQL
I have a very simple data structure with just 3 tables: requests employees teams Basically, what I need is to concatenate 2 different SQL selects into one (so that the query could return just one row). If there’s an employee associated with a request, then return their name (title) and concatenate it with ‘ / ‘. Then, if there’s a
How do you UNION 2 tables based having a primary Key with different fields in either table?
Given this scenario: I have 2 tables, 1 named Books and the other Customers that look like this – The customers table has a BookTitle field that has the name of books the customer acquired from another Source (or they could be books they can manual enter into that field) The Books table can have the same Customer as in