Question

In pgAdmin, i have a employee table( name, salary) like this    Name salary TOM 3000...

In pgAdmin, i have a employee table( name, salary) like this   

Name salary
TOM 3000
Jack 2000
Mike 6000
Susan 3000
Chris 5000
Nancy 5000

If i do select name, salary, densen_rank() over (order by salary desc ) as AA from table ,it'll return me a table like this

Name Salary AA
Mike 6000 1
Chris 5000 2
Nancy 5000 2
Suan 3000 3
Tom 3000 3
Jack 2000 4

Is there anyway i can write a query and return me just a specific employee and the rank of his salary? Like (Tom,3), or (chris,2) . I don't want a whole table.

Thnaks a lot!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You can do use the where clause like this:

select name, salary, dense_rank() over (order by salary desc ) as AA from table where Name="Tom"

Or if you want to search for someone by rank

select name, salary, dense_rank() over (order by salary desc ) as AA from table where AA=2

Add a comment
Know the answer?
Add Answer to:
In pgAdmin, i have a employee table( name, salary) like this    Name salary TOM 3000...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

    SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male 4500 Canada 3 Pam Female 5500 USA 4 Sara Female 4000 Canada 5 Todd Male 3500 Canada 6 Mary Female 5000 UK 7 Ben Male 6500 UK 8 Elizabeth Female 7000 USA 9 Tom Male 5500 UK 10 Ron Male 5000 USA Given the EMPLOYEE table above, write a query that would produce the output below. COUNTRY    GENDER     Total Salary ---------- ---------- ------------ Canada     Female             4000 Canada     Male               8000 UK         Female             5000...

  • SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

    SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male 4500 Canada 3 Pam Female 5500 USA 4 Sara Female 4000 Canada 5 Todd Male 3500 Canada 6 Mary Female 5000 UK 7 Ben Male 6500 UK 8 Elizabeth Female 7000 USA 9 Tom Male 5500 UK 10 Ron Male 5000 USA Given the EMPLOYEE table above, write a query that would produce the output below. COUNTRY    GENDER     Total Salary ---------- ---------- ------------ Canada     Female             4000 Canada     Male               8000 Canada     NULL              12000...

  • JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and...

    JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and position. You will also define the type of company. Is it an engineering firm, a supermarket, or a call center? Once the application has been completed, I should be able to perform a query for any piece of information associated with each employee.   For instance, if I search for employees who make over $50,000, all of the employees whose salaries are greater than $50,000 should...

  • JAVA: How do I output all the data included for each employee? I can only get...

    JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...

  • Q2. Retrieve the names of all employees from the employee table to produce output on CSV...

    Q2. Retrieve the names of all employees from the employee table to produce output on CSV format or delimited format with a common delimeter, rather than separete columns. Hint:Put the whole row into a string with a semicolon as the seperator(delimeter) between thecolumns: FORMAT:(fname;minit;lname) Example: EMPLOYEES -------------- James;E;Borg Frank;T;Wong Q3. Write a query to show the employees name from the employee table in this format: first letter of the first name, followed by a dot, a blank, and the full...

  • (Using Oracle SQL) How do I find the primary key of this table? And then how...

    (Using Oracle SQL) How do I find the primary key of this table? And then how do I consequently drop the primary key from the table? Edit: I was already give this code and it did not work select constraint_name,constraint_type from user_constraint where table_name='CUSTOMER'; Q7 (10 Points) Use ONE SQL statement to find out the name of the primary key constraint defined on Customer table. (Your SQL should return something like SYS_C0021715, numbers on your account may differ.) Then use...

  • I really need help with this, please. This is a java programming assignment. Project 1 The first programming project inv...

    I really need help with this, please. This is a java programming assignment. Project 1 The first programming project involves writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes. 1. The first class is the Employee class, which contains the employee's name and monthly salary, which is specified in whole dollars. It should have three methods: a. A constructor that allows the name and monthly salary to be...

  • I have written my code for an employee management system that stores Employee class objects into...

    I have written my code for an employee management system that stores Employee class objects into a vector, I am getting no errors until I try and compile, I am getting the error: C2679 binary '==': no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion). But I am not sure why any help would be great, Thank you! 1 2 3 4 5 6 7 8 9 10 11 12 13...

  • THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed...

    THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed separately. Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever separator suits you. How do I do this? How would you change what I have in to it getting into that kind of input. Thank you! class Employee: again = 'y' def __init__(self): self.__rate = 7.25 self.__totalhour = 0 self.__regularpay = 0 self.__overtimepay = 0 self.__totalpay = 0 self.__tax...

  • i have a group project that I need do and im currently stuck for my section...

    i have a group project that I need do and im currently stuck for my section of and i really need help. Word (Unlicensed Product) References Mailings Review View Help ramirogarcia2365@gmail.com Tell me what you want to do A L A À AS - x x AA AaBbced AaBbcod AaBbc Aabbcc AaB AabCD Abcd Abend 1 Normal 1 No Spac. Heading 1 Heading 2 Title Subtitle Subtle Em Emphasis Font Paragraph Styles The BA213 Corporation would like you to perform...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT