Viewing 15 posts - 826 through 840 (of 1,923 total)
Try this:
declare @table table
( catid int, catname varchar(25) , refid int )
insert into @table values
(1 ,'Lenovo', 21),
(2 ,'Sony', 22),
(2 ,'Sony', 22),
(3 ,'Dell', 23),
(4 ,'Toshiba', 24),
(4 ,'Toshiba', 24)
; with cte as
(
...
April 27, 2011 at 9:47 pm
Seems to be a normal GROUP BY solution to me;
Here it is:
SELECT PT.ridParentTable , PT.ParentName , PT.Address1 , PT.Address2,
COUNT(CT.ChildName) Child_Count
FROM ParentTable PT
JOIN...
April 27, 2011 at 8:36 pm
In Option 2 , as its an assignment-to-variable operation, the query has to scan ( or seek ) through the entire table and will assign the last value it retrieved...
April 27, 2011 at 12:20 am
I would advice you to use Aliases for the tables and then run the query.. probabaly some outer query is accessing the columns of the inner query..
April 26, 2011 at 1:49 pm
How abt this?
declare @table table
( col1 varchar(250))
insert into @table (col1)
values ('abc123 , xyz789') ,
('a1 , z9 ' ) ,
...
April 26, 2011 at 12:55 pm
😀 3 replies 🙂 with the same answer 😉
April 26, 2011 at 12:25 pm
Because that an INTEGER division; Interger division will round off the result to the nearest lower integer. Try this instead
Print (5596.00 / 11784.00)
April 26, 2011 at 12:24 pm
I was mulling over this problem and i found a bug with my code; So i came back running to fix it up :w00t:
So here is the hopefully successful (:-P)...
April 21, 2011 at 1:55 am
How about this?
declare @table table
(
col1 varchar(10),
col2 varchar(10),
col3 varchar(10),
col4 varchar(10)
)
insert @table values ( 'apple','boy',null, 'cat')
; with cte as
(
select * ,
RN = ROW_NUMBER() over( order by...
April 21, 2011 at 12:08 am
Will this help you?
SELECT * FROM
(
SELECT * , COUNT_DIST = COUNT(*) OVER(PARTITION BY ADM_NO , FIRST_NAME)
...
April 20, 2011 at 11:53 pm
Cross Post.. Please direct your replies to this http://www.sqlservercentral.com/Forums/Topic1096236-149-1.aspx
April 20, 2011 at 11:53 pm
bitbucket-25253 (4/20/2011)
Now let me admonish you once more. You obviously did NOT test your detail information before posting. Other wise you would have discovered that
INSERT [dbo].[tb_studentDetails] ([Adm_no],...
April 20, 2011 at 11:51 pm
Will this help you?
SELECT * FROM
(
SELECT * , COUNT_DIST = COUNT(*) OVER(PARTITION BY ADM_NO , FIRST_NAME)
FROM [tb_studentDetails]
) SUB_Q
WHERE COUNT_DIST = 1
April 20, 2011 at 11:46 pm
Use HAVING clause
Like HAVING (sum(colA) <> 0 and sum(colB) <>0 )
April 11, 2011 at 9:59 pm
Viewing 15 posts - 826 through 840 (of 1,923 total)