I have the following table users id | phone ————– 1 | +1111 2 | +2222 3 | +3333 4 | +4444 5 | +1111 I need to get all ids, where users have duplicate phone. For …
How can I find duplicate records in clickhouse [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 want to know how I can find duplicate data entries within one table in clickhouse. I am act…
SQL PIVOT-WINDOW FUNCTIONS
With the sql query I get table 1 table 1 Trying to pivot using window functions below on Server 2012 fails My desired output Answer Use conditional aggregation Also, you can try with pivot –
sql- suppressing the amount value to get the unique value when its multiple rows of same information
Sorry for the confused title. I am on Teradata 16.1, I have two tables, one is a simple table with id and amount and another one is a detailed table with sub id’s and their amounts. In the second …
SQL Searching not working form a particular starting element only ‘a’ and ‘e’
This is my code SELECT * FROM `contacts` WHERE name = ‘a%’ AND name = ‘e%’; but I’m getting error so, how to display records in the table which is starting from a and e? This is my error:- #1064 – …
Capture logging for stored procedure in Postgresql
We are working on a reporting project where we are executing stored procedures to perform transformations on the source data and convert it into the desired format. The transformed data will be inserted into a different table. We would like to know what are the best practices that needs to be implemented in t…
Python – Running a SQL in a loop based on column value
I am trying to build a SQL query that runs based on certain conditions (if a column is filled run Query 1 else Query 2 and so on) as shown below: I am trying to build something like the above but the number of fields as variable (fields like col_a and col_b) are 6 in number. Is there a way
parse string containing comma in csv using mysql? (or maybe pandas?)
(I’m using mysql v5.7) I have a csv file that has something like mytable1 note that ‘aaa,bbb,ccc’ is one string and ‘8,3,5’ is one string.. I know it’s not a good practice putting data like this but this is what I have given from other department… so my first task was…
Determining what index to create given a query?
Given a SQL query: How do you determine what index to write to improve the performance of the query? (Assuming every value to the right of the equal is calculated at runtime) Is there a built in command SQL command to suggest the proper index? To me, it gets confusing when there’s multiple JOINS that us…
MySQL (Percona) Error 1452: Cannot add or update a child row for no reason
I have 2 Database Tables “users” and “tasks”. The tasks table contains two foreign keys for the createdBy_user_id and updatedBy_user_id columns both referencing users.id. If I try to insert an entry to tasks (after making sure the user referenced by the foreign keys exists) like this: …