Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Please Help me to Remove Duplicate records - OpenERP ver 7 or 6.1.1 [Closed]

By
priyankahdp
on 4/24/13, 1:34 AM 5,982 views

The Question has been closed

by
priyankahdp
on 04/30/2013 10:25:59

I want to get Employee ID,Leave Reason,Leave type and Employee name for my internal report purpose.i wrote a sql query to retrieve those data and i got some duplicates also. seems its missing some join / foreign id mapping part missing

select
   h.id as employee_id,h.name as leave_reason,
   s.name,r.name as res_name
from 
   hr_holidays_status s,
   hr_holidays h,
   hr_employee e,
   resource_resource r
where 
   h.employee_id=e.id and 
   h.holiday_status_id=s.id and
   e.resource_id=r.id
order by 
   resource_id
1

Gustavo

--Gustavo--
950
| 2 1 4
Buenos Aires, Argentina
--Gustavo--

Python developer, big fan of sailing

Gustavo
On 4/24/13, 4:59 PM

You need to add the group by clause to your query

select
   h.id as employee_id,h.name as leave_reason,
   s.name,r.name as res_name
from 
   hr_holidays_status s,
   hr_holidays h,
   hr_employee e,
   resource_resource r
where 
   h.employee_id=e.id and 
   h.holiday_status_id=s.id and
   e.resource_id=r.id
group by 1,2,3,4
order by 
   resource_id

thanks User 12569 its worked :-)

priyankahdp
on 4/25/13, 2:56 AM
2
Dharmesh Rathod
On 4/25/13, 1:04 AM

Hi,

GROUP BY clause will help you to remove duplicate records.

To improve this query and execution time, use LEFT JOIN instead of define all tables in FROM.

Email: info@acespritech.com
Skype: acespritech

please can u tell me above query with Left Join.?

priyankahdp
on 4/25/13, 2:55 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/24/13, 1:34 AM
Seen: 5982 times
Last updated: 3/16/15, 8:10 AM