TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
firas shaar
NA
15
17.7k
How to use alias and sum them together in select query
Oct 16 2014 5:46 AM
I have the following queries below. I'd like to use the aliases and add them together but SQL does not allow that. Any suggestions on how I can go about this without repeating the queries again? Using Microsoft SQL Server 2008
SqlCommand command = new SqlCommand(@"SELECT Workers.Full_Name,Workers.Salary,
CASE WHEN (SUM(JobHours.Additional_Time)) > 0 THEN (SUM(JobHours.Additional_Time)) ELSE (0) END AS Plusovertime,
CASE WHEN (SUM(JobHours.Additional_Time)) > 0 THEN ROUND(((Workers.Salary/300)*1.5),0) ELSE (0) END AS PlusRental,
(Plusovertime+PlusRental) AS PULSNET
FROM Workers INNER JOIN JobHours ON Workers.Worker_ID = JobHours.Worker_ID
WHERE Jobhours.Start_Work BETWEEN @startdatetime AND @enddatetime
GROUP BY Workers.Worker_ID, Workers.Full_Name,Workers.Salary
ORDER BY Workers.Worker_ID;", conn);
Reply
Answers (
1
)
saving values in xml and retrieving them
Rename file extensions in a unknown directory using c#