I have two tables work_table and progress_table.
work_table has following columns:
id[primary key],
department,
dept_name,
dept_code,
created_time,
updated_time
progress_table has following columns:
id[primary key],
project_id,
progress,
progress_date
I need only the last updated progress value to be updated in the table now am getting duplicates.
Here is the tried code:
select
row_number() over (order by a.dept_code asc) AS sno,
a.dept_name,
b.project_id,
p.physical_progress,
DATE(b.updated_time) as updated_date,
b.created_time
from
masters.dept_users as a,
work_table as b
LEFT JOIN
progress as p on b.id = p.project_id
order by
a.dept_name asc
It shows the duplicate values for progress with the same id how to resolve it?[the progress values are integer whose values are feed to the form]
Having reformatted your query, some things become clear...
,andJOINsyntax (why!?)masters.dept_userstable, but don't mention it in your descriptiondept_usersandwork_tablesno, but have nopartition byand never use itAnd to top it off, you use meaningless aliases like
aandb? Please for the love of other, and your future self (who will try to read this one day) make the aliases meaningful in Some way.You possibly want something like...
That at least shows how to get that latest progress record (
p.seq_num = 1), but whether the other joins are correct is something you'll have to double (and triple) check for yourself.