Hive DBMS; Two tables — A and B Table A Table B Question –> Trying to execute a query where: Join table A with table B, first on prnt_id, if it’s “unknown”, then join on sub_id, if that is “unknown”, join on ac_nm Desired Output: Answer You must use LEFT joins of T…
Tag: sql
Group by expression with case statement in oracle?
I have a query with case statement in it. This query gives me error ORA-00979: not a GROUP BY expression When I remove my last case statement from select then it runs fine. Please help me in this Answer Columns that aren’t aggregated should be part of the GROUP BY clause. It means that “solution&#…
SQL Select from many-to-one
I have two tables containing a one-to-many relationship. How should I select the “one” side given information for the “many” side? I’m using SQLite. Let’s say our first table, T1, is about cars and the second table, T2, is about the imperfections in each car. Let’s sa…
Joining Temp Tables Using Indexes
I’m just beginning to learn about INDEX and I’ve heard it could speed up results but my testing is having the opposite effect. Some points about the data: My company uses a SQL Server but I don’t know much else beyond that I’m just an employee and don’t have any sort of admin acc…
How find row by exact much of joined rows with SQL?
I have two tables I want to find specific row from parent table with name A which have exact two related rows in child table with names a and b. In example table is only one row is suitable (with id = 1). Row with id = 2 is not suitable because name of parent is B. Row with id
SQL Server – Ordering Combined Number Strings Prior To Column Insert
I have 2 string columns (thousands of rows) with ordered numbers in each string (there can be zero to ten numbers in each string). Example: The end result is to combine these 2 columns, sort the numbers in ascending order and then put each number into individual columns (smallest, 2nd smallest etc). e.g. Cols…
SQL ~ How to sort alphabetically WHEN value is same
I have table like this ordered in DESC order by value “key”: I want to sort it alphabetically when the key value is same So I want it to be like this: How can I do that? Answer Just use two order by keys:
I am trying to get the user id which is created automatically [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 most code I can find but nothing works Answer Assuming these lines of code come immedi…
Filtering by dates saved as strings in SQL [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I’m developing a program in Java that saves medical information of e…
Booking Time slot, with Equipment Stock query, in Laravel
Here’s an interesting one for you all. I’ve found myself in a implementation conundrum. I’m developing a booking app in Laravel that allows people to book rooms and equipment for spaces at specific times. The amount of equipment available is limited, so the amount of stock has to be queried …