Tuesday, March 27, 2012
Distinct?
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
?
How to do that? I need join just the distinct Id from a table with other
table...
Is it possible to be done ?
You could do this:
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
(select distinct EmployeeID from SomeTable) A join EmpTable B on EmpTable.ID
= A.EmployeeID
Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> ?
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>
|||SELECT Distinct SomeTable.EmployeeID ,EmpTable.EmployeeName from
SomeTable
INNER JOIN EmpTable ON SomeTable.EmployeeID = EmpTable.ID
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> ?
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>
Distinct?
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
'
How to do that? I need join just the distinct Id from a table with other
table...
Is it possible to be done ?You could do this:
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
(select distinct EmployeeID from SomeTable) A join EmpTable B on EmpTable.ID
= A.EmployeeID
Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> '
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>|||SELECT Distinct SomeTable.EmployeeID ,EmpTable.EmployeeName from
SomeTable
INNER JOIN EmpTable ON SomeTable.EmployeeID = EmpTable.ID
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> '
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>sql
Distinct?
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
'
How to do that? I need join just the distinct Id from a table with other
table...
Is it possible to be done ?You could do this:
Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
(select distinct EmployeeID from SomeTable) A join EmpTable B on EmpTable.ID
= A.EmployeeID
Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> '
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>|||SELECT Distinct SomeTable.EmployeeID ,EmpTable.EmployeeName from
SomeTable
INNER JOIN EmpTable ON SomeTable.EmployeeID = EmpTable.ID
--
Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com
"Paulo Roberto" <paulo.roberto@.edt.com.br> wrote in message
news:eIucQTDRIHA.5400@.TK2MSFTNGP04.phx.gbl...
> Hi,
> Select Distinct(SomeTable.EmployeeID), EmpTable.EmployeeName from
> SomeTable,EmpTable Where EmpTable.ID = * Distinct(SomeTable.EmployeeID) *
> '
> How to do that? I need join just the distinct Id from a table with other
> table...
> Is it possible to be done ?
>
Thursday, March 22, 2012
distinct count
Hi
I have a table which stores the shift information for employees. The table contains 10 columns as Employeename,Employeeno,month,year,shifttimings etc. If an employee works a day in a particular shift, then a row will be inserted in to the above table for that employee.
Now at the end of the month i wanted to calculate the shift details for each employee for a particular month of a given year like employeename,employeeno, noofdays(countof shiftdays).
Can some body help?
Thanks in Advance!
Santhosh
Select
Employee.EmployeeName,
Employee.EmployeeNo,
|||Select EmployeeName, EmployeeNo, Count(*) As NoOfDays
From EmployeeShift
Where Month = @.Month And Year = @.Year
Group By EmployeeName, EmployeeNo
|||You could create a view as
Select EmployeeName, EmployeeNo, Month, Year, Count(*) As NoOfDays
From EmployeeShift
Group By EmployeeName, EmployeeNo, Month, Year
and apply Where to it...
sql