To learn a little bit how a back end application works i’m currently creating a small instagram-like app using nodejs and sequelize (reactjs for the front). I have 3 SQL tables : Users id (pk) username email password Posts id (pk) userId (fk) message mediaUrl Following id (pk) userId (fk) followingId (f…
Tag: sql
Teradata merge multiple records into single record
I want to merge multiple record into single record Ex: Input pdt status start_dt end_dt a Inactive 2022/02/02 2022/02/04 a Inctive 2022/02/05 2022/02/10 a Active 2022/02/10 2022/02/12 b Active 2022/03/13 2022/03/17 Output pdt status start_dt end_dt a Active 2022/02/02 2022/02/12 b Active 2022/03/13 2022/03/17…
Calculate years based on months in SQL Server
I want to write a function that takes the number of months as a parameter and does the following: I can hardcode all of this using case statements but I wanted to know if there is a dynamic way of doing it. Thanks! Answer Try this:
How to avoid showing duplicate rows because conditions
The problem is where name_1 writes something to name_2 and name_2 writes something to name_1 there is a duplicate and as one result because I SELECT name_1, name_2 with condition How is it possible to show results with no duplicate rows, I only want to know if there is communication between user_1 and user_2 …
This Oracle SQL SELECT shouldn’t work. Why does it?
I am debugging a query in Oracle 19c that is trying to sort a SELECT DISTINCT result by a field not in the query. (Note: This is the wrong way to do it. Do not do this.) This query is trying to return a unique list of customer names sorted with the most recent sale date first. It returns an
Unpivot Access Data Table
Good afternoon, I would like to unpivot an Access Table. I have almost one hundred of columns in Access and one column with the ID and I would like to unpivot, considering all the columns except de ID into one column called “type” (for example). How could I get it from Access? It doesnt matter if …
Invalid path in HQL and weird substitutions
I hope you can help me with this. I am working on the upgrade of a customized installation of DSpace from 5.5 to 6.3 and I am running into a weird issue with HQL. The SQL that I am trying to implement is this: and this is the HQL that I wrote in my code and it is supposed to
SQL Conditional Print Statement
I am working on two different tables: sales and inventory. From the table inventory, there’s Quantity_Received and from the table sales, there’s Quantity_Sold. Quantity Remaining in Store represents the difference between Quantity_Received and Quantity_Sold. When the Quantity Remaining in Store is…
max DISTINCT returns multiple rows
I am working on an sql script which is executed by a .bat daily and outputs a list of IDs, the date of access, and their level. While it returns what I want, mostly, I noticed that some of the outputted rows are duplicates. Could someone please help me modify my script so that it outputs only one date (the
how to include 0 results in count with group by in HIVEQL
I’m a newbie in HIVE. I want to include 0 rows in results I have one table like this is my query example result is but my desired result is How can I get a 0 in results? Answer You can do this but you need to remove where clause. You can also do using self join. EDIT – I