Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

In SQL Query: I have three tables A, B, and C, each table having employee and their salary, I want to get the high salary from each table in one table.

Dear all,

Can anyone help me out below the SQL query, please?

I have three tables A, B, and C, each table having employee and their salary, I want to get the high salary from each table in one table.

What is the SQL query for this, below the one example tables.

Ex: Table A

Employee

Salary

David

66000

Michel

60000

Richard

56000

Daniel

72000

Maxwell

80000

Ronald

75000

Table B

Employee

Salary

Raj

90000

Krish

55000

Mohan

71000

Mary

69000

Alex

120000

Soham

92000

Table C

Employee

Salary

Trump

45000

Modi

59000

Greek

76000

Joshi

61000

Kevin

83000

Charlet

74000

Output would be like these

Table D

Employee

Salary

Alex

120000

Kevin

83000

Maxwell

80000

12 Replies
sunny_talwar

You are looking for an SQL query or do you want to do this in QlikView?

Not applicable
Author

‌Hello Sunny Glad to you.

This query belongs to SQL database but if you are okay - I wish to see both queries in SQL and Qlikview.

Mean while I can compare what's the differences between both queries.

Thanks,

Bob.

ziadm
Specialist
Specialist

SELECT Employee, Max(Salary) as Salary FROM tableA

Group by Employee

UNION

SELECT Employee, Max(Salary) as Salary FROM tableB

Group by Employee

UNION

SELECT Employee, Max(Salary) as Salary FROM tableC

Group by Employee;

Not applicable
Author

‌HI Ziad,

I appreciated your response,

Still I have confuse Group by is used for aggregated, if apply Group by to employee column, its aggregates to employee.

Could you please explain me once.

Thanks,

Bob

Anil_Babu_Samineni

Sunny, How to do in Qlikview? For ref, PFA.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ziadm
Specialist
Specialist

Hi Anil

Employees:


Load Employee, Max(Salary) as Salary FROM tableA

Group by Employee

Concatenate

SELECT Employee, Max(Salary) as Salary FROM tableB

Group by Employee

Concatenate

SELECT Employee, Max(Salary) as Salary FROM tableC

Group by Employee;

Anil_Babu_Samineni

I don't think so this is workable. But thanks. Have a look of my attachment

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Not applicable
Author

Hi Anil,

I'm unable to open that attachment, getting Qlikview error

PFA error messageQlikview_Error.png

sunny_talwar

Anil -

One option is to do it like this:

TableA:

LOAD *,

  'TableA' as Flag;

LOAD * Inline [

Employee, Salary

David, 66000

Michel, 60000

Richard, 56000

Daniel, 72000

Maxwell, 80000

Ronald, 75000

];

TableB:

LOAD *,

  'TableB' as Flag;

LOAD * Inline [

Employee, Salary

Raj, 90000

Krish, 55000

Mohan, 71000

Mary, 69000

Alex, 120000

Soham, 92000

];

TableC:

LOAD *,

  'TableC' as Flag;

LOAD * Inline [

Employee, Salary

Trump, 45000

Modi, 59000

Greek, 76000

Joshi, 61000

Kevin, 83000

Charlet, 74000

];

FinalTable:

NoConcatenate

LOAD Flag,

  Max(Salary) as MaxSalary,

  FirstSortedValue(Employee, -Salary) as EmployeeWidMaxSalary

Resident TableA

Group By Flag;

Capture.PNG