Click here to Skip to main content
15,903,030 members
Home / Discussions / Database
   

Database

 
AnswerRe: Plz help me...(Urgently)... Pin
Mycroft Holmes21-Mar-09 14:56
professionalMycroft Holmes21-Mar-09 14:56 
JokeRe: Plz help me...(Urgently)... Pin
Arslan Khan22-Mar-09 9:00
Arslan Khan22-Mar-09 9:00 
GeneralRe: Plz help me...(Urgently)... Pin
Mycroft Holmes22-Mar-09 13:19
professionalMycroft Holmes22-Mar-09 13:19 
QuestionRewrite sql for Oracle and MySQL? Pin
devvvy20-Mar-09 1:12
devvvy20-Mar-09 1:12 
AnswerRe: Rewrite sql for Oracle and MySQL? Pin
Ashfield20-Mar-09 2:13
Ashfield20-Mar-09 2:13 
QuestionCan Microsoft SQL server work with Windows Vista home basic? Pin
RogerLum19-Mar-09 15:47
RogerLum19-Mar-09 15:47 
AnswerRe: Can Microsoft SQL server work with Windows Vista home basic? Pin
N a v a n e e t h19-Mar-09 20:31
N a v a n e e t h19-Mar-09 20:31 
QuestionCalculations Pin
Terick19-Mar-09 9:32
Terick19-Mar-09 9:32 
Hi,

I need to create a table in SQL that will compute costs. I have to read in some information from two other tables and use this to populate the new table from which the costs are calculated. As the data is from a website, it is possible that it will change and I need the costs to update if the data changes. Do I need to create a function to do this, or will the table do it on its own? ( I elected to do a function, but if there is a better way I am open to that)

This is what I have so far:
set ANSI_NULLS ON
go
set QUOTED_IDENTIFIER ON
go

CREATE FUNCTION [dbo].[fcn_computecosts]
( @ProjectID int, @userID int, @startDate datetime, @enddate datetime, @quarter tinyint, 
@Cost money, @percent int, @totalDays int, @totalcost)

RETURNS @ComputeCosts TABLE
( ProjectID int, userID int, startDate datetime, enddate datetime, quarter tinyint, 
Cost money, percent int, totalDays int, totalcost)

AS
BEGIN
SELECT
 P.ProjectID, P.userID, P.startDate, P.enddate, C.quarter,P.Cost, P.percent,
COUNT(C.date) AS totalDays, ((percent/100)*totaldays*Cost*8) AS totalcost

FROM Project AS P INNER JOIN Calendar AS C ON Calendar.date >P.startDate AND Calendar.date <=
P.enddate
WHERE (C.isWeekday =1) AND (C.isHoliday=0)
GROUP BY P.ProjectID, P.userID, P.startDate, P.enddate, C.quarter,P.Cost, P.percent,
 totalDays,  totalcost
ORDER BY P.ProjectID
RETURN
END


However when I run this I am getting the following error: "msg 207, Level 16, state 1: Invalid column
name 'totalDays', 'totalcost', 'Cost'

Please help!
AnswerRe: Calculations Pin
David Mujica19-Mar-09 10:25
David Mujica19-Mar-09 10:25 
AnswerBad group Pin
David Mujica19-Mar-09 10:31
David Mujica19-Mar-09 10:31 
AnswerRe: Calculations Pin
Isaac Gordon21-Mar-09 2:09
Isaac Gordon21-Mar-09 2:09 
QuestionProblem while importing the data into sql server 2005 . Pin
Pankaj Garg19-Mar-09 8:05
Pankaj Garg19-Mar-09 8:05 
AnswerRe: Problem while importing the data into sql server 2005 . Pin
knagnayak30-Mar-09 1:02
knagnayak30-Mar-09 1:02 
QuestionCounting fields Pin
stevemarsh9919-Mar-09 8:05
stevemarsh9919-Mar-09 8:05 
AnswerRe: Counting fields Pin
Blue_Boy19-Mar-09 8:35
Blue_Boy19-Mar-09 8:35 
AnswerRe: Counting fields Pin
Seren Singh20-Mar-09 1:09
Seren Singh20-Mar-09 1:09 
AnswerRe: Counting fields Pin
Seren Singh20-Mar-09 1:14
Seren Singh20-Mar-09 1:14 
GeneralRe: Counting fields Pin
Blue_Boy20-Mar-09 4:55
Blue_Boy20-Mar-09 4:55 
QuestionMaking Decisions in T-SQL??? Pin
Seren Singh19-Mar-09 5:33
Seren Singh19-Mar-09 5:33 
Answersp_help Pin
David Mujica19-Mar-09 6:22
David Mujica19-Mar-09 6:22 
GeneralRe: sp_help Pin
Seren Singh19-Mar-09 20:01
Seren Singh19-Mar-09 20:01 
AnswerRe: Making Decisions in T-SQL??? Pin
Seren Singh20-Mar-09 1:01
Seren Singh20-Mar-09 1:01 
QuestionSQL '#define' statement Pin
RChin19-Mar-09 4:21
RChin19-Mar-09 4:21 
AnswerDynamic SQL Pin
David Mujica19-Mar-09 4:40
David Mujica19-Mar-09 4:40 
AnswerRe: SQL '#define' statement Pin
Eddy Vluggen19-Mar-09 5:19
professionalEddy Vluggen19-Mar-09 5:19 

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.