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...
Thanks to everyone that responded. I was able to use the code that gmmastros provide. However I need to incorporate the ratio calculation into the following sql:
SELECT Project_1.ProjectName, Project_1.OpCo, Project_1.Plant, Project_1.StartDate, Project_1.EndDate...
I need to sum several fields then take product and use it in another calculation. For example:
select sum(day_hrs)+sum(night_hrs)+sum(day_ot_hrs)+sum(night_ot_hrs) as total_hrs from Craft where weeklyuid = @weekid and craft_category = 'Boilermaker'
select...
I need to calculate the following formula within an sql statement:
--Tsat = Ax + B/x + C(x^0.5) + D(ln(x)) + E(x^2) + F(x^3) + G
My first attempt is like so:
Local a real;
Local b real;
Local c real;
Local d real;
Local e real;
Local f real;
Local g real;
Local Tsat real;
Local P real;
a =...
I was able to figure it out.
SELECT Tbl1.Ts, Tbl1.Max AS Skin1Max, Tbl2.Max AS Skin2Max, Tbl2.Max+Tbl1.Max as SkinSum
FROM
(SELECT ts,max,sum FROM aggregates WHERE name = '3B-HP-DRM-SKIN-1-T' AND ts between '14-JUN-06 07:32' AND '14-JUN-06 22:26') Tbl1
INNER JOIN
(SELECT ts,max,sum FROM...
Thanks for the help with the code. Im using the following:
SELECT Tbl1.Ts, Tbl1.Max AS Skin1Max, Tbl2.Max AS Skin2Max
FROM
(SELECT ts,max FROM aggregates WHERE name like '3B-HP-DRM-SKIN-1-T' AND ts between '14-JUN-06 08:32' AND '14-JUN-06 22:26') Tbl1
INNER JOIN
(SELECT ts,max FROM...
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.