I´m using Pandas in Python and I’d like to join 2 dataframes. My first dataframe is: id var date 1 ABCD 2019-01-01 1 ABCD 2017-06-01 1 ABCD 2016-06-01 2 ABCD 2016-01-01 The dataframe I want to …
Tag: join
Select info from row to another row
I have this select on a view: And get this: And I want that the last row be like this: That is, the values of all columns equal to the other rows, except column ‘C’ and column ‘D’. The value of column D is obtained from T2.D How can I do? Thanks. Answer Without any sample data to use I
I was asked the following pseudocode in a SQL interview based on joining condition. Can anyone explain what went went wrong with my approach?
[two tables-ta and tb with respective columns ] I was asked to put a LEFT JOIN on item id and explain what would be the possible output. I wrote a pseudocode like this- I told them the output would look like this, which they told is not the right answer. Can anyone explain what would be the correct answer along
How to do a join to get previous days values?
I want to join tables as follow: Report_Period Entity Tag Users Count Report_Period_M-1 Report_Period_D-1 … 2021-03-31 entity 1 X 471 2017-05-31 2021-03-18 … 2020-12-31 entity 2 A 135 2020-11-30 2021-03-18 … 2020-11-30 entity 3 X 402 2020-10-31 2021-03-18 … With a view containing Day – 1 results as follow : Report_Period Entity Tag Users Count Report_Period_D-1 2021-03-31 entity 1 X
SQL Server filling gaps in time series
I’m having trouble with a request in SQL. I have two tables, one representing a vector of dates and another timeseries of prices for different securities: Dates: DateId Date 1 2021-01-01 2 2021-01-02 3 2021-01-03 TimeSerie: SecurityId DateId Value 1 1 0.25 1 3 0.32 2 1 0.41 2 2 0.67 The timeserie may have gaps, for example in the
Spark SQL : filtering a table on records which appear in another table (two columns)?
I have several tables, and I would like to filter the rows in one of them, based on whether two columns are present in another table. The data on each table is as follows Table1 : one hash can be associated to several articles ; one article can be associated to several hashes User Hash Article Name Hash1 Article1 Hash1
Oracle SQL – need to flip values, but don’t know how
This is the output, but I need those values changed. I have ID primary keys for both – kasutaja and riistvara, but I don’t know how to match kasutaja ID 1 with riistvara ID 2 and vice versa. And the output should be like this: The R_NIMETUS and SEERIA_NR fields are different on my output what I get with my
How to join two tables and add a limit
Given two tables in a SQLite database, app_vendor app and I am trying to get 10 ‘names’ from ‘app’ (names of apps) for a given ‘vendor_id’ What am I doing wrong? Answer Your WHERE clause is in the wrong location. You can do: Result: See running example at DB Fiddle.
All categories for each week and group
Hi I have a data source as such Data: Weeknum Group Priority Total 202106 A High 10 202106 B Medium 15 202107 A Medium 88 Priorities: Priority High Medium Low The data has already been grouped such that each weeknum+group+priority is unique. What I need to do is return the full list of priorities for each week/group including zeros: Weeknum
How to insert into a SQL table column using SELECT query?
I have tables A, B, and C. I want to insert UserRoleName values in table C, into UserRoleName column in table A for the corresponding UserId. UserId in Table A, is a foreign key from Table B. UserRoleId is a foreign key in table B from table C. How can I do that? I tried using this query, But this