Click here to Skip to main content
15,905,963 members
Home / Discussions / Database
   

Database

 
GeneralRe: Referential Integrity Pin
Rob Graham20-Apr-08 3:58
Rob Graham20-Apr-08 3:58 
GeneralRe: Referential Integrity Pin
Adeel Chaudhry20-Apr-08 18:11
Adeel Chaudhry20-Apr-08 18:11 
QuestionHow to start Synchronizing from Script ( for Sql 2000 Merge Replication) Pin
RichardBlare17-Apr-08 23:42
RichardBlare17-Apr-08 23:42 
AnswerRe: How to start Synchronizing from Script ( for Sql 2000 Merge Replication) Pin
Mark J. Miller21-Apr-08 5:59
Mark J. Miller21-Apr-08 5:59 
GeneralRe: How to start Synchronizing from Script ( for Sql 2000 Merge Replication) Pin
RichardBlare24-Apr-08 3:50
RichardBlare24-Apr-08 3:50 
GeneralSql server Reporting Pin
Ballita17-Apr-08 23:24
Ballita17-Apr-08 23:24 
GeneralRe: Sql server Reporting Pin
Mark J. Miller21-Apr-08 6:04
Mark J. Miller21-Apr-08 6:04 
GeneralWarning: Null value is eliminated by an aggregate or other SET operation Pin
hyderalishah17-Apr-08 18:48
hyderalishah17-Apr-08 18:48 
I m using this SP in SQL 2005 and Getting this error plz help me

Warning: Null value is eliminated by an aggregate or other SET operation


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go






ALTER procedure [dbo].[systek_salesRpt]
@username varchar(50) = NULL,
@RoleID int = NULL,
@ItemTitle varchar(50) = NULL,
@jumpid int
AS
BEGIN
CREATE TABLE #saletemp
(

SubscriptionID int,
Noofsales int,
subscriberID int ,
OwnerID int,
Rolename varchar(50),
Type varchar(50),
Itemid int,
Totalprice float,
Commission float,
RoleID int,
ItemTitle varchar(50),
CreatedDate DateTime,
Username varchar(50)

)
INSERT INTO #saletemp(SubscriptionID,Noofsales,subscriberID,OwnerID,Rolename,Type,Itemid,Totalprice,Commission,RoleID,ItemTitle,CreatedDate,UserName)
SELECT B.SubscriptionID,
COUNT(B.SubscriptionID) AS noofsales,
A.SubscriberID,A.UserID AS OwnerID,
C.RoleName,B.Type,
ISNULL(D.VideoID,'') AS ItemID,
ISNULL(SUM(B.price),0) AS TotalPrice,
ISNULL(SUM(A.Commission),0) AS Commission,A.RoleID,
D.VideoTitle as ItemTitle,B.CreatedDate,H.userName
FROM
(SELECT * FROM Systek_UserCommissions WHERE Systek_UserCommissions.Module = 'videos')A
LEFT OUTER JOIN
(SELECT * FROM Systek_Subscription WHERE Type='videos')B
ON A.SubscriberID = B.UserID
LEFT OUTER JOIN
(SELECT * FROM SIC_Roles )C
ON C.RoleID = A.RoleID
INNER JOIN
(SELECT * FROM systek_videos)D
ON D.VideoID = B.ProductID OR D.VideoID = A.itemid
LEFT OUTER JOIN
(SELECT * FROM systek_Series)E
ON E.SeriesId = D.SeriesId OR E.SeriesId = B.ProductID OR E.SeriesId = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM SIC_SmartThinker_Group)F
ON F.GroupID = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM Systek_VideoProducer)G
ON A.UserID = G.userID
LEFT OUTER JOIN
(SELECT * FROM sic_users)H
ON H.UserID = G.UserID OR B.UserID = H.UserID
GROUP BY
B.SubscriptionID,A.SubscriberID,A.UserID,C.RoleName,B.Type,D.VideoTitle,
E.SeriesId,F.GroupID,D.VideoID,A.RoleID,B.CreatedDate,H.UserName

UNION ALL

------------------------------------------------------------------series-------------------------------------------------------------------------

SELECT B.SubscriptionID,
COUNT(B.SubscriptionID) AS noofsales,
A.SubscriberID,A.UserID AS OwnerID,
C.RoleName,B.Type,
ISNULL(E.SeriesId,'') AS ItemID,
ISNULL(SUM(B.price),0) AS TotalPrice,
ISNULL(SUM(A.Commission),0) AS Commission,A.RoleID,
E.seriesTitle as ItemTitle,B.CreatedDate,H.userName
FROM
(SELECT * FROM Systek_UserCommissions WHERE Systek_UserCommissions.Module = 'series')A
LEFT OUTER JOIN
(SELECT * FROM Systek_Subscription WHERE Type='series')B
ON A.SubscriberID = B.UserID
LEFT OUTER JOIN
(SELECT * FROM SIC_Roles )C
ON C.RoleID = A.RoleID
LEFT OUTER JOIN
(SELECT * FROM systek_videos)D
ON D.VideoID = B.ProductID OR D.VideoID = A.itemid
LEFT OUTER JOIN
(SELECT * FROM systek_Series)E
ON E.SeriesId = D.SeriesId OR E.SeriesId = B.ProductID OR E.SeriesId = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM SIC_SmartThinker_Group)F
ON F.GroupID = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM Systek_VideoProducer)G
ON A.UserID = G.userID
LEFT OUTER JOIN
(SELECT * FROM sic_users)H
ON H.UserID = G.UserID OR B.UserID = H.UserID
GROUP BY
B.SubscriptionID,A.SubscriberID,A.UserID,C.RoleName,B.Type,D.VideoTitle,
E.SeriesId,F.GroupID,D.VideoID,A.RoleID,E.seriesTitle,B.CreatedDate,H.userName

UNION ALL

-----------------------------------------------------------group id----------------------------------------------------------------------------
SELECT B.SubscriptionID,
COUNT(B.SubscriptionID) AS noofsales,
A.SubscriberID,A.UserID AS OwnerID,
C.RoleName,B.Type,
ISNULL(F.GroupID,'') AS ItemID,
ISNULL(SUM(B.price),0) AS TotalPrice,
ISNULL(SUM(A.Commission),0) AS Commission,A.RoleID,
F.GroupName AS ItemTitle,B.CreatedDate,H.userName
FROM
(SELECT * FROM Systek_UserCommissions WHERE Systek_UserCommissions.Module = 'Groups')A
LEFT OUTER JOIN
(SELECT * FROM Systek_Subscription WHERE Type='Groups')B
ON A.SubscriberID = B.UserID
LEFT OUTER JOIN
(SELECT * FROM SIC_Roles )C
ON C.RoleID = A.RoleID
LEFT OUTER JOIN
(SELECT * FROM systek_videos)D
ON D.VideoID = B.ProductID OR D.VideoID = A.itemid
LEFT OUTER JOIN
(SELECT * FROM systek_Series)E
ON E.SeriesId = D.SeriesId OR E.SeriesId = B.ProductID OR E.SeriesId = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM SIC_SmartThinker_Group)F
ON F.GroupID = A.ItemID
LEFT OUTER JOIN
(SELECT * FROM Systek_VideoProducer)G
ON A.UserID = G.userID
LEFT OUTER JOIN
(SELECT * FROM sic_users)H
ON H.UserID = G.UserID OR B.UserID = H.UserID
GROUP BY
B.SubscriptionID,A.SubscriberID,A.UserID,C.RoleName,B.Type,D.VideoTitle,
E.SeriesId,F.GroupID,D.VideoID,C.RoleID,A.RoleID,F.GroupName,B.CreatedDate,H.username
----------------------------------------------------removing duplicate subscrptionid---------------------------------------------------------
DECLARE @Count int
DECLARE @SubsCriptionID AS int
DECLARE vendor_cursor CURSOR
FOR
SELECT SubscriptionID,Count(SubscriptionID) - 1 FROM #saletemp Where RoleName <> 'smartIcast' GROUP BY SubscriptionID HAVING Count(subscriptionid) > 1
OPEN vendor_cursor
FETCH NEXT FROM vendor_cursor INTO @SubsCriptionID,@Count
WHILE @@FETCH_STATUS = 0
BEGIN
SET ROWCOUNT @Count
DELETE FROM #saletemp WHERE #saletemp.SubscriptionID = @SubsCriptionID
SET ROWCOUNT 0
FETCH NEXT FROM vendor_cursor INTO @SubsCriptionID,@Count
END
CLOSE vendor_cursor
DEALLOCATE vendor_cursor

----------------------------------------------------------------------------------------------------------------------------------------------
IF @jumpid = 0
BEGIN
SELECT subscriptionid,noofsales,subscriberid,ownerid,Rolename,Type,itemID,
'$' + (CAST(ROUND(TotalPrice,2) AS Varchar)) AS TotalPrice,
'$' + (CAST(ROUND(Commission,2) AS Varchar)) AS Commission,
RoleID,ItemTitle,CreatedDate,UserName
FROM #saletemp

END

IF @jumpid = 1

BEGIN
SELECT subscriptionid,noofsales,subscriberid,ownerid,Rolename,Type,itemID,
'$' + (CAST(ROUND(TotalPrice,2) AS Varchar)) AS TotalPrice,
'$' + (CAST(ROUND(Commission,2) AS Varchar)) AS Commission,
RoleID,ItemTitle,CreatedDate,UserName
FROM #saletemp
Where
RoleID = @RoleID
OR
ItemTitle LIKE '%'+ @ItemTitle + '%'
OR
username LIKE '%' + @username + '%'
END

DROP TABLE #saletemp

END
GeneralRe: Warning: Null value is eliminated by an aggregate or other SET operation Pin
Ashfield17-Apr-08 19:53
Ashfield17-Apr-08 19:53 
GeneralToo many results Pin
John R. Shaw17-Apr-08 15:22
John R. Shaw17-Apr-08 15:22 
GeneralRe: Too many results Pin
Blue_Boy17-Apr-08 15:51
Blue_Boy17-Apr-08 15:51 
General[Message Deleted] Pin
John R. Shaw17-Apr-08 15:57
John R. Shaw17-Apr-08 15:57 
GeneralRe: Too many results Pin
Blue_Boy17-Apr-08 16:11
Blue_Boy17-Apr-08 16:11 
GeneralRe: Too many results Pin
John R. Shaw18-Apr-08 8:55
John R. Shaw18-Apr-08 8:55 
GeneralRe: Too many results Pin
Blue_Boy18-Apr-08 11:15
Blue_Boy18-Apr-08 11:15 
Generaldata transformation problem for serialised recordsets Pin
uglyeyes17-Apr-08 9:30
uglyeyes17-Apr-08 9:30 
GeneralRe: data transformation problem for serialised recordsets Pin
Michael Potter17-Apr-08 10:08
Michael Potter17-Apr-08 10:08 
GeneralRe: data transformation problem for serialised recordsets Pin
uglyeyes17-Apr-08 13:23
uglyeyes17-Apr-08 13:23 
GeneralRe: data transformation problem for serialised recordsets Pin
Blue_Boy17-Apr-08 15:45
Blue_Boy17-Apr-08 15:45 
GeneralRe: data transformation problem for serialised recordsets Pin
uglyeyes17-Apr-08 16:48
uglyeyes17-Apr-08 16:48 
GeneralRe: data transformation problem for serialised recordsets Pin
Michael Potter18-Apr-08 3:57
Michael Potter18-Apr-08 3:57 
GeneralRe: data transformation problem for serialised recordsets Pin
uglyeyes19-Apr-08 17:26
uglyeyes19-Apr-08 17:26 
GeneralRe: data transformation problem for serialised recordsets Pin
Michael Potter21-Apr-08 3:22
Michael Potter21-Apr-08 3:22 
GeneralGrid sorting wont work on live server (Godaddy) [modified] Pin
AlexeiXX317-Apr-08 5:42
AlexeiXX317-Apr-08 5:42 
Questionhow to change the date 5 th dec 2008 to default date in sqlserver2000? Pin
subbu.sk17-Apr-08 3:59
subbu.sk17-Apr-08 3:59 

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.