I have a view that returns the following:
select * from latest_report
projectname contractor_name date
Barry O&M Vulcan 01/01/2007
Barry O&M Vulcan 02/01/2007
Barry O&M Vulcan...
I have tried the following but it did not work:
CREATE PROCEDURE spDupeWeek
-- @wuid = current week we are working with
-- @wuid_copy = week we want to copy data from
@wuid uniqueidentifier,
@wuid_copy uniqueidentifier
AS
BEGIN
Insert Into Craft(week_Uid,craft_ID,craft_group...
I would like to duplicate some records in a table. The table name is Craft and it has the following fields:
id - integer (Identity = Yes)
week_UID - uniqueidentifier
craft_ID - integer
craft_group - integer
craft_name - nvarchar
craft_category - nvarchar
craft_count - integer...
Thanks again for the help ... Here is the actual code I have so far ( I know it's alot diffrent from my initial post but I was trying to keep if simple)
SELECT top 100 percent end_date, craft_category, craft_name, day_of_week, day_count, night_count,
max(subtotal) AS max_count_week...
Thanks for the reply. I think your code is very close to what I need, however I will need to be stepping through many weeks and I need the maximum for each week.
Dave
I need help with the following:
I have two tables. The first table, Craft_temp, contains the following fields:
craftID craft_group craft_name craft_cateogry
1 1 Carpenter A Carpenter
2 2 Carpenter B Carpenter
3...
OK I was able to get the function to work! SQLSister, thanks again for the suggestion to use a function to get the results I needed.
Thanks for everyone's help.
Dave
SQLSister,
Thanks for the suggestion on creating the User Defined Function. I think this is the way I want to go. I've created the following function:
CREATE FUNCTION dbo.ratio (@weekid varchar(75), @category varchar(50))
RETURNS decimal
AS
BEGIN
Declare @TotalHours decimal
Declare...
Yes I have a table that contains all possible crafts. What I'm trying to do is create a report on the data you see above and I need to calculate the ratio of Apprentice to Journeyman.
Dave
Thanks for the tip on the float data type, I made the changes. What I'm trying to do is calculate the ratio of Journeymen to Apprentice. The above stored procedure works nicely but for only the craft type that is passed in via the @category parameter. Here's what the data looks like:
craft...
Let me try to simplify this some.
I use the above sql code to return data from a table. Now what I would like to do is on each row that is returned I would like to run the following stored procedure:
CREATE PROCEDURE spCalcRatio
@weekid varchar(75),@category varchar(25)
AS
BEGIN...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.