Click here to Skip to main content
15,888,461 members
Home / Discussions / Database
   

Database

 
AnswerRe: Get start date Pin
SilimSayo8-Dec-11 10:49
SilimSayo8-Dec-11 10:49 
QuestionHow to Call A web service inside SQL server Pin
yousefshokati7-Dec-11 17:30
yousefshokati7-Dec-11 17:30 
AnswerRe: How to Call A web service inside SQL server Pin
David Skelly7-Dec-11 22:26
David Skelly7-Dec-11 22:26 
GeneralRe: How to Call A web service inside SQL server Pin
yousefshokati8-Dec-11 0:28
yousefshokati8-Dec-11 0:28 
AnswerRe: How to Call A web service inside SQL server Pin
SilimSayo8-Dec-11 8:27
SilimSayo8-Dec-11 8:27 
QuestionExporting and Importing data from and into SQL Server 2008 Pin
SQL Ed7-Dec-11 2:58
SQL Ed7-Dec-11 2:58 
AnswerRe: Exporting and Importing data from and into SQL Server 2008 Pin
Blue_Boy7-Dec-11 3:11
Blue_Boy7-Dec-11 3:11 
QuestionSum the counts from two different tables Pin
Elizabeth Rani7-Dec-11 1:04
Elizabeth Rani7-Dec-11 1:04 
Hi All,

Iam new to database. Here iam using sql server 2000. i want to sum the counts from two different tables. I need this to calculate the employees who have taken continuous leaves in a week/month.

Example: I have three table such as

Table1:tbl_attandence(it contains the employee id and the intimings and outtime)
Fields:empcode,intime,outime

Eg: EMP001,11/24/2011 09:30:45 AM,11/24/2011 04:30:15 PM

Table2:tbl_leaveentry(it contains the leave dates taken by an employee)
Fields:empcode,entrydate

Eg: EMP001,11/25/2011

Table3:tbl_holidays(it contains the list of holidays such as sunday,saturday,chrismas,newyear....)
Fields:holidays,days

Eg: 11/25/2011,sunday

I am attaching my code such that it return the sum but iam unable to return the employee name and id because it is showing the result as null as the holidays does not match

please help me in completion of process

select sum(counts)
from(
select a.empcode as empcode,b.name,count(*) as counts from tbl_leaveentry a,tbl_emp b
where a.empcode=b.empcode
and a.empcode='EMP001'
and a.entrydate between '11/24/2011'; and '11/27/2011'
group by a.empcode,b.name
union
select null,null,count(*) as counts from tbl_holidays
where holidays between '11/24/2011' and '11/27/2011'
) as c having sum(counts)>=3


the above code returns correct sum but if i add name before the sum and execute the result is not been summed because holidays does not match with the leaves

Please suggest that how can i do this task any help will be appreciated
AnswerRe: Sum the counts from two different tables Pin
Corporal Agarn7-Dec-11 8:46
professionalCorporal Agarn7-Dec-11 8:46 
AnswerRe: Sum the counts from two different tables Pin
SilimSayo7-Dec-11 12:50
SilimSayo7-Dec-11 12:50 
GeneralRe: Sum the counts from two different tables Pin
Elizabeth Rani7-Dec-11 19:46
Elizabeth Rani7-Dec-11 19:46 
GeneralRe: Sum the counts from two different tables Pin
SilimSayo8-Dec-11 3:25
SilimSayo8-Dec-11 3:25 
Questioncreate user account Pin
Danzy835-Dec-11 15:40
Danzy835-Dec-11 15:40 
AnswerRe: create user account Pin
Mycroft Holmes5-Dec-11 16:52
professionalMycroft Holmes5-Dec-11 16:52 
GeneralRe: create user account Pin
Danzy835-Dec-11 21:57
Danzy835-Dec-11 21:57 
QuestionIntegration Services or C# code Pin
RichardInToronto5-Dec-11 15:00
RichardInToronto5-Dec-11 15:00 
AnswerRe: Integration Services or C# code Pin
Mycroft Holmes5-Dec-11 16:49
professionalMycroft Holmes5-Dec-11 16:49 
GeneralRe: Integration Services or C# code Pin
Jörgen Andersson5-Dec-11 20:30
professionalJörgen Andersson5-Dec-11 20:30 
GeneralRe: Integration Services or C# code Pin
RichardInToronto7-Dec-11 15:35
RichardInToronto7-Dec-11 15:35 
AnswerRe: C# code Pin
David Mujica6-Dec-11 5:55
David Mujica6-Dec-11 5:55 
GeneralRe: C# code Pin
RichardInToronto7-Dec-11 4:09
RichardInToronto7-Dec-11 4:09 
GeneralRe: C# code Pin
David Mujica7-Dec-11 8:08
David Mujica7-Dec-11 8:08 
GeneralRe: C# code Pin
RichardInToronto7-Dec-11 15:31
RichardInToronto7-Dec-11 15:31 
GeneralRe: C# code Pin
Mycroft Holmes7-Dec-11 15:55
professionalMycroft Holmes7-Dec-11 15:55 
Questiondatabase role permissions Pin
Danzy835-Dec-11 3:53
Danzy835-Dec-11 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.