Viewing 3 posts - 1 through 3 (of 3 total)
you can use the following code to get the desired O/P-
SELECT CityName,StateName FROM @Cities where CityName NOT IN (SELECT distinct CityName from @Cities WHERE StateNAme = 'ALL')
Thanks,
Anand
August 24, 2016 at 6:26 am
Hi,
you can try with below approach-
declare @t table(Parent_ID char(1),Child_ID char(1))
insert @t values ('A','B'),('C','D'),('B','C'),('B','E'),('E','F')
select t1.Parent_ID,t1.Child_ID,isnull(t2.count+t3.t3_cnt,1) Level from @t t1 left join
(select Parent_ID,count(Child_ID)count from @t group by Parent_ID) t2
on t1.Parent_ID=t2.Parent_ID
left join (select...
July 19, 2016 at 5:56 am
Hi,
Please try using following code-
DECLARE @T TABLE (ID INT, NAME VARCHAR(1))
INSERT @T VALUES (1000,'A'),(990,'C'),(980,'A'),(970,'A'),(960,'B'),(950,'C'),(930,'A')
SELECT * FROM(SELECT ROW_NUMBER() OVER( PARTITION BY NAME ORDER BY ID DESC)ROWNUM,ID,NAME FROM @T )T
WHERE T.ROWNUM<=3
Regards,
Anand
July 5, 2016 at 5:34 am
Viewing 3 posts - 1 through 3 (of 3 total)