1 Replies - 453 Views - Last Post: 10 April 2014 - 04:40 AM

#1 nataliafoster26   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 21-February 12

how can i join this two query?

Posted 09 April 2014 - 06:53 PM

I have two table table employee and CSEReduxResponses
In table employee i have
CREATE TABLE [dbo].[employee](
[emp_id] [int] IDENTITY(1,1) NOT NULL,
[emp_namefirst] [varchar](255) NOT NULL,
[emp_namemiddle] [varchar](50) NULL,
[emp_namelast] [varchar](255) NOT NULL


)
on responds i have
CREATE TABLE [dbo].[CSEReduxResponses](
[response_id] [int] IDENTITY(1,1) NOT NULL,
[employee] [int] NOT NULL,
[employeedept] [int] NOT NULL,
[star] [tinyint] NOT NULL,
[status] [int] NOT NULL,
[approvedby] [int] NULL,
[approveddate] [datetime] NULL,
[execoffice_status] [int] NULL,

)
Im trying to get the employee with the MAX execpffice_status( this is either a 1 or 0).
i have this query that i made for it
select top(1) with ties employee, SUM(execoffice_status) as 'total'
from   CSEReduxResponses
group by employee
order by 'total' desc 


my query for employee table is
  select emp_namefirst as first , emp_namelast as [last]
from phonelist.dbo.employee where emp_namefirst is not null  


How can i get this 2 query together so i can output the employee (first and last )name
with the max exeoffice_status?

Is This A Good Question/Topic? 0
  • +

Replies To: how can i join this two query?

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3038
  • View blog
  • Posts: 11,678
  • Joined: 03-December 12

Re: how can i join this two query?

Posted 10 April 2014 - 04:40 AM

SQL JOIN examples
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1