I was able to get the duplicate records and I wanted to retain 1 record per item barcode based on the createdate (oldest) sample script of getting the duplicate records: output: final output should be like this: (retain the items that has the oldest createdate from the 2 duplicate Barcodes) Answer I guess you…
Tag: sql
Multiple inner joins in pymysql
I am attempting to select multiple columns from three tables in pymysql, and inner join them. I don’t understand what is going wrong when I add the second inner join. I feel like it’s a simple syntax …
How to make it to select from 1st day every month
Hello there I have a question so I have a goal mysqli query and it sum the price and select by interval 1 month I try few things to made it to select only from 1st day of the month but I have no idea …
Select with IF statement on postgresql
I have a code like that: select tbl.person ,COUNT(distinct tbl.project) ,if (tbl.stage like ‘%SIGNED%’) then sum(tbl.value) else ‘0’ end if as test from my_table tbl group by 1 And …
Many to many join behaviour
Not really sure how to title this question, but here’s the situation. I have one data frame (dfOrders) that has an order_id and basic information like so: |order_id|full_name|order_date|billing|…
SQL Retrieve info from two tables
I am really lost with sql.. i tried to read everything but no luck. I have two tables and need to retrieve data from them: First Table – Workers | Second Table – Stores Select workers first name that belong to more than one store? Select all workers first name that are in the shoe store? Hope you …
get sum of all rows with id from main query
I need the sum of all positions from one year for every customer. In the subquery i’ve hardcoded the customernumber (mark 1) but it needs to be another customernumber for every row. The values in mark 2 are wrong. Thanks for your help! Answer If BAS_Customers and BAS_Contacts have a one-to-one relations…
MySQL: How to hold lock and make other threads wait for an insert that hasn’t happened yet
I’m confronted by a seemingly simple problem that has turned out to be pretty hard to figure out. We want to keep a record of every time we’re presented with a piece of marketing (a lead) so we don’t …
How to merge many rows with the same ID with SQL Server
I need the help from the community to solve the following problem that I found (I’m using SQL Server): I have two tables, USER and INFO. USER: ID NAME ———- AAA John BBB Mike INFO: ID …
Is it possible to remove milliseconds from TO_TIMESTAMP function
I have this query which gives me this output its fine except for .000000000 part. I dont need that part, and im not sure how its coming up if its HH:MI:SS format this is for oracle sql developer. Answer Why not just convert to a date? That datatype doesn’t have fractions of a second: