GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 31 of 188    Print  
Giving two tables:

EmpCust
EmpName, CustID, EmpID
April, 1, A
April, 3, A
April, 2, A
Bruce, 4, B
Bruce, 5, B
Carson, 2, C
Carson, 1, C
Carson, 3, C
David, 2, D

CustReview
CustID, ReviewDate, EmpID
1, 01-05-06, A
1, 12-13-05, C
2, 07-04-04, A
2, 05-21-03, C
2, 04-02-03, D
3, 10-10-02, A
3, 02-01-06, C
4, 01-01-06, B
5, 12-12-04, B

Write a SQL statement that return each EmpName and LATEST ReviewDate. Result should look like this:

EmpName, ReviewDate
April, 01-05-06
Bruce, 01-01-06
...

  
Total Answers and Comments: 2 Last Update: April 27, 2008     Asked by: zanhsieh 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 11, 2006 04:54:28   #1  
ratna_ponnapalli Member Since: April 2006   Contribution: 4    

RE: Giving two tables:EmpCustEmpName...
select a.empname,max(b.reviewdate) from empcust a,custreview b where a.custid=b.custid group by a.empname;
 
Is this answer useful? Yes | No
April 27, 2008 14:05:43   #2  
vishalb Member Since: April 2008   Contribution: 2    

RE: Giving two tables:EmpCustEmpName, CustID, EmpIDApril, 1, AApril, 3, AApril, 2, ABruce, 4, BBruce, 5, BCarson, 2, CCarson, 1, CCarson, 3, CDavid, 2, DCustReviewCustID, ReviewDate, EmpID1, 01-05-06, A1, 12-13-05, C2, 07-04-04, A2, 05-21-03, C2, 04-02-03
Tested!

SELECT E.EmpName, Max(C.Reviewdate) from
EmpCust E Join CustReview C on e.Empid=c.empid
group by c.empid, E.EmpName

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : If you are trying SQL Server 2000, try the code that gives the size in bytes...DECLARE @CalSize TABLE( TabID INT, ColSize INT)INSERT INTO @CalSize SELECT A.id, SUM(A.Length) As Length FROM  (Select Length, id from ...

Can we use aggregate function in another aggregate functionsuppose we got count of a column by using the group by clause so we get different counts in the same statement how to get the maximum of count
Read Answers (11) | Asked by : sahithi

Latest Answer : yes, here is an exampleSQL> CREATE OR REPLACE TRIGGER tab1_trig  2    AFTER insert ON tab1  3  DECLARE  4    PRAGMA AUTONOMOUS_TRANSACTION;  5  BEGIN  6    INSERT INTO ...
Read Answers (17) | Asked by : suresh

In Mysql, which one character is used to complete the query and get the input. In other words, we can write the query in multiple lines. How to terminate the query?
semicolon ' ; ' 
Read Answers (1) | Asked by : Bindu Puvvala

Hey there SQL MASTERS, here are some questions i was posed in an interview/assessment thing, dunno how well i did....Coud u answer these questions? i dont know how easy/difficut they are for u, all i know is that i had SERIOUS trouble with them! thanks alot!EMPLOYEEEmployee_id number NOT NULL (Primary Key)Employee_name VarChar(30) NOT NULL Dept_id number NOT NULL (Foreign Key to DEPARTMENT)Manager_id number NOT NULL (Foreign Key to EMPLOYMENT)Salary number
Read Answers (6) | Asked by : zen

Select 1 from dualunionselect 'A' from dual; I guess the query will select zero rows. Is it wrong or right ? if wrong thenWhat will be the result set for the query?Thanks in advance.
Read Answers (4) | Asked by : Rachana

I am writing a script to update a value in an Oracle table. The script has a 'From' clause which Oracle does not like. Is there another way to write this since I am bringing data from 3 different tables.ThanksSamir
Read Answers (1) | Asked by : Samir

Having following table named RATING :EmpID,ReviewSeason,CustID1,s1,c11,s1,c21,s2,c32,s2,c22,s3,c43,s3,c5Write a SQL statement, return EmpID who has been REVIEWED more than once.
Read Answers (3) | Asked by : zanhsieh

Giving two tables:EmpCustEmpName, CustID, EmpIDApril, 1, AApril, 3, AApril, 2, ABruce, 4, BBruce, 5, BCarson, 2, CCarson, 1, CCarson, 3, CDavid, 2, DCustReviewCustID, ReviewDate, EmpID1, 01-05-06, A1, 12-13-05, C2, 07-04-04, A2, 05-21-03, C2, 04-02-03, D3, 10-10-02, A3, 02-01-06, C4, 01-01-06, B5, 12-12-04, BWrite a SQL statement that return each EmpName and LATEST ReviewDate. Result should look like this:EmpName, ReviewDateApril, 01-05-06Bruce, 01-01-06...
Read Answers (2) | Asked by : zanhsieh

My problem is i have a two tablestable1customercustid custnametable2custaddrcustaddrid custaddrstr custid datei have different records for each custid in custaddr table. say for example for the first customer we have 6 records in custaddr table. so i want the latest dated record from the custaddr table. ie to find the maximum date. pls somebody can write the query for this, i have tried but not able to find the max of the dates.thanks in advance


 Sponsored Links

 
Related Articles

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf("%d",printf("%d %d %d", a,a,a)); } In this above program the inner printf i
 

What is the default return value of a function?

The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.   When a programmer wants other than integer values to be returned from function then it is essential that the pro
 

exit and return statements

  How does the exit () and return () differ exit () is used to exit the program as a whole. In other words it returns control to the operating system. After exit () all memory and temporary storage areas are all flushed out and control goes out of program. In contrast, the return () stateme
 

What are the limitations with switch statement?

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below: Logical operators cannot be used with switch statement. For instance case k>=20: is not allowe
 

goto Statement

Why to avoid goto in C C has goto statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us understand the goto statement, its
 

How To Use Proper English When You are Giving a Speech

How To Use Proper English When You are Giving a Speech For many of us giving a speech is one of the most daunting tasks we could ever engage in You have to stand up in front of a group of people and you must speak to them about various concepts or ideas You may be nervous and if the people don t und
 

How To Write The Main Heading For Your Essay

How To Write The Main Heading For Your Essay When you write an essay you will want to make sure you write a good heading To write a good heading you will need to plan your essay very effectively If you remember any good points from lectures these could be things you may want to use to create a good
 

How To Write a Good Essay

How To Write a Good Essay While there are many different methods you can use to write an essay standard essays will follow specific formats Understanding the basic format of an essay will allow you to write informative articles which will capture the attention of those that read it mosgoogle The fir
 

How To Write A College Essay

How To Write A College Essay The best way to write a college essay is to start by brainstorming ideas You will also want to make a list of topics you re interested in While there are other ways you can write a college level essay this method is the easiest mosgoogle When you brainstorm you will want
 

How To Write A Killer Resume

How To Write A Killer Resume When you apply for a job it can be argued that your resume is the single most important factor to whether or not you will be hired It is not uncommon for people to spend days making sure they create the perfect resume mosgoogle Making even small mistakes on your resume c
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape