I have the following model: BASE_LIST: in this table we store base lists. Base list can be for example the list of cities in a continent, types of automobiles in a shop etc. ELEMENT: in this table we store the elements of base lists. For example the cities and the car types are here (Budapest, London, Paris, …
Pivot(transpose) by some columns SQL
I’m looking to transpose by some columns in my table. I have something like the following example: ╔════════╦═══════╦══════╦══════╦═════════╦══════╦═══════╦═══════╦═══════╦═══════╦═══════╦═══════╦═════……
How to replace rows in Hive database using HQL
I’m trying to filter out a hive database df project schedule timestamp p1 1 t1 p1 2 t1 p1 3 t1 p2 1 t2 p2 2 t2 I want to …
Update table and add new column with check for all rows for UserName numbers | SQL Server
I need add this script ALTER TABLE [dbo].[MyTable] ADD [MyNewColumnCheckUserName] BIT NOT NULL DEFAULT 0; But after the update, I need to check all old rows in MyTable – all UserName (it is …
Compare the values in the successive rows and display newly added or deleted items in a different columns
I have a database with date and list of items. The problem this I do have an event date captured whenever an item is added or deleted. So what I am trying to do is comparing the items for a user ‘A’ on different days (successive rows); here the newly added or deleted items for user ‘A’…
How to determine the number of days in a month for a given Date Range?
I need to calculate using SQL Query, how many days within a given range fall into each calendar month. I have given 2 dates, which define a date range; for example 2020-01-01 to 2020-08-03. I need to find how many days in that range fall in to each month i.e. how many fall into July, and how many into August.
MySQL – Recursively list all parents and ancestors of all items in table
I have a table with a parent/child hierarchy that supports multiple (theoretically infinite) levels of nesting: I am trying to build a query that produces a concatenated list of every item’s parent items up until the highest parent in the tree: Based on a number of other answers here I have constructed …
SQL Server – Generate a column value which satisfy same condition in a day
I have a transaction table (Tran_Table) that contains Account Number, Transaction Date, Transaction Amount. I would like to generate a column that has “Yes” or “No” info in case if a transaction repeated in same day with same amount for same customer. Table and generated value example …
SQL : Select all column after a distinct count = 1
In sql, I am trying to do that : I have a (staging) table with let say 8 columns 4 of these column are primary key of main table in which I need to insert the data of staging table 1 column is the operation of the column (I for Insert, U for Update, D for Delete) 3 are the
Filling missing dates in each group while querying data from PostgreSQL
I have data in my table of the following form: Now while querying this data, I want the missing dates to be filled with null values. In PostgreSQL, I can use generate_series() to create a series of dates and then left join with it. But that only works if I have just a series of dates and values. In this