i have employee table with 3 coloums
emp name companyname experience
1 1 3.5
2 2 4.0
1 1 2.6
2 2 3.0
3 3 5.0
i want the result table like this
emp name comany name experience
1 1 6.1
2 2 7.0
3 3 5.0
anyone tell me the sql query for this ?

Recommended Answers

All 11 Replies

What have you tried? You give no example code, so we have no information to help you with .. looks like a simple case of sorting and grouping to me.

select unique or select distinct?

Looking at the numbers hes adding the results together.

commented: Well noticed with a fine eye! +4

Yeah LizR, remarkable sight you have!

select sum(experience) from table... where...?

Well Ive given some big hints up earlier too.. but yes, the SQL for it should be a real simple 1 line uncomplex answer.. Im interested to see what the original posters tried so far.

That wasn't easy for me to see and if you hadn't pointed it out I don't know if I would have caught it.

how in the world did you see that randomly?

Because to me its obvious :) - Im that odd.

Of course it would help if the initial poster could define their requirements in proper terms it would help them help themselves.

Far too many posts are a bunch almost nonsensical jabberings and with a final comment of all but "code please" .. if you cant define clearly what you want, its highly likely you wont be able to code it either.

I am not clear about your table because what is entity in your table.

SELECT
E.empname, E.companyname as 'Company Name', Sum(E.experience) as 'Experience'
FROM employee E
GROUP BY E.empname, E.companyname

really thanks for ur great help

If its fixed, then mark it as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.