Viewing 15 posts - 211 through 225 (of 321 total)
select p.name,
sum(CASE WHEN nStatus=1 0 else nSpeed end ),sum(nLineTotal)
from statusTable st join product p ON
st.pdtno = p.pdtno
group by p.name,
st.publyear,
st.issord,
st.pdtrnno
June 22, 2005 at 7:53 am
This one I think is should work properly:
CREATE FUNCTION [dbo].[FUNCTION_NAME]
(@Pos int, @MyNumb int)
RETURNS varchar(400)
AS
BEGIN
DECLARE @TempResult varchar(400)
DECLARE @MinValue int
DECLARE @NewValue int
SELECT @MinValue=SUM(Value) FROM MyTable WHERE Col<=@Pos
IF @MyNumb>@MinValue RETURN...
June 22, 2005 at 6:44 am
I m done for today .... : )
I ll check the post tommorrow cause this can be done without RECURSIVITY
June 21, 2005 at 3:13 pm
I don't have them anymore ....
SET NOCOUNT ON
DECLARE @Values TABLE
(
Value NUMERIC(10,2)
Col int identity(1,1)
)
/* 20 or more values that are available */
INSERT INTO @Values (Value) VALUES (10)
INSERT INTO...
June 21, 2005 at 3:12 pm
This is MyTable:
Value Col
----------- -----------
10 1
15 2
21 3
25 4
26 5
30 6
30 7
40 8
41 9
45 10
50 11
55 12
60 13
60 14
65 15
70 16
75 17
80 18
85 19
90 20
95 21
100 22
105 23
this...
June 21, 2005 at 3:07 pm
105 95 85 75 65 60 50 41 30 21
This is the result
(with my last version that I posted)
in the original table was value 10 after 15 that has...
June 21, 2005 at 3:02 pm
For last function the call changes :
SET NOCOUNT ON
DECLARE @myAmount NUMERIC(12,2) SET @myAmount =160 -- SET THIS VALUE AS VALUE TO BE FOUND
DECLARE @MyCol int
SELECT @MyCol=MAX(Col)+1 FROM MyTable
SELECT dbo.FUNCTION_NAME(@MyCol,@myAmount)
June 21, 2005 at 2:55 pm
CREATE FUNCTION [dbo].[FUNCTION_NAME]
( @Pos int, @MyNumb int)
RETURNS varchar(400)
AS
BEGIN
DECLARE @TempResult varchar(400)
DECLARE @MinValue int
DECLARE @NewValue int
SELECT @MinValue=SUM(Value) FROM MyTable WHERE Col<=@Pos
IF @MyNumb>@MinValue RETURN ''
--check to see if a number matches myValue
IF...
June 21, 2005 at 2:51 pm
And the flaw seems to be here : )
--check to see if a number matches myValue
IF EXISTS(SELECT Value FROM MyTable WHERE Value=@MyNumb )
RETURN ' ' + LTRIM(STR(@MyNumb))
is in fact...
June 21, 2005 at 2:16 pm
Srry for delay I m quite busy ATM
the last code I posted semmed to work fine
I ll check again
883 doesn't match in my code... have to check
June 21, 2005 at 2:02 pm
CREATE FUNCTION [dbo].[FUNCTION_NAME]
(
@Pos int,
@MyNumb int
)
RETURNS varchar(400)
AS
BEGIN
DECLARE @TempResult varchar(400)
DECLARE @MinValue int
DECLARE @NewValue int
SELECT @MinValue=SUM(Value) FROM MyTable WHERE Col<@Pos
IF @MyNumb>@MinValue RETURN ''
--check to see if a number matches myValue
IF EXISTS(SELECT...
June 21, 2005 at 1:03 pm
Remember that if you want to use SQl you have to be carefull about
Nested stored procedure levels | 32 |
cause you won't be safe if...
June 21, 2005 at 12:50 pm
Replace
SELECT @NewValue=MAX(Value), @Pos=MAX(Col) FROM MyTable WHERE Value<@MyNumb
with
SELECT @NewValue=MAX(Value), @Pos=MAX(Col) FROM MyTable WHERE Value<@MyNumb and Col<@Pos
June 21, 2005 at 12:45 pm
Ups : ))
I m missing here the part where you actually put some data in MyTable srry
June 21, 2005 at 12:41 pm
Small improvement to func since is TSQL... : )
CREATE FUNCTION [dbo].[FUNCTION_NAME]
(
@Pos int,
@MyNumb int
)
RETURNS varchar(400)
AS
BEGIN
DECLARE @TempResult varchar(400)
DECLARE @MinValue int
DECLARE @NewValue int
--check to see if a number matches myValue
IF EXISTS(SELECT...
June 21, 2005 at 12:36 pm
Viewing 15 posts - 211 through 225 (of 321 total)