Jump to content

sql babulu ravali


nenu_devudni

Recommended Posts

create table #table1
(
id varchar(10),
name varchar(10)
)

insert into #table1 values ( '1', 'sam')
insert into #table1 values ('2', 'ram')

select * from #table1

create table #table2
(
id varchar(10),
number varchar(10)
)

insert into #table2 values ( '1', '456')
insert into #table2 values ('1', '789')

insert into #table2 values ( '2', '023')
insert into #table2 values ('2', '956')


select * from #table1
id  name
1	sam
2	ram


select * from #table2
id  number
1	456
1	789
2	023
2	956

select p.* from 
(
select a.id, a.name, b.number,  ROW_NUMBER() OVER(PARTITION BY b.id ORDER BY b.id )  as new_id 
from #table1 a right outer join #table2 b
on a.id = b.id
)p 
where p.new_id = 1
id  name number new_id
1	sam	  456	 1
2	ram	  023	 1

Posted Image

Link to comment
Share on other sites

35 minutes ago, loveindia said:

aa select statement ki aa result ki relation ekkada undi man? Date field edanna undaa aa query lo... intaki aa 5 records which is the one you want to see man?

 

34 minutes ago, loveindia said:

;WITH CTE AS(
SELECT 
SELECT *
FROM CTE 
WHER Rnum = 1

 

something like this will help you man...

edi google lo chusinay vuncle ...kani etla vadalo ardam kale ..tanks .. oo sari na util lo petti try chesi chepta .. ^^

Link to comment
Share on other sites

2 minutes ago, nenu_devudni said:

 

edi google lo chusinay vuncle ...kani etla vadalo ardam kale ..tanks .. oo sari na util lo petti try chesi chepta .. ^^

ide cheyyali man for ur result set.. enjoy man.... 

Link to comment
Share on other sites

love india vuncle ... neku future lo kidney avasaram unte sepp .. tesi ichesta ..ur logic worked great ya ... extract tesi ma odi mohana kotta .. #~`

Link to comment
Share on other sites

1 minute ago, nenu_devudni said:

love india vuncle ... neku future lo kidney avasaram unte sepp .. tesi ichesta ..ur logic worked great ya ... extract tesi ma odi mohana kotta .. #~`

endi man ippudu neeku code raasina papaniki naa kidney povalnaa.... yabbbeeeeey......

Link to comment
Share on other sites

love thatha .. nu esina post lo .. aa table name gatra update seyva .. ma appice lo evadu aina google sesi ee post kanapadaithe .. na drawyer sinigipodi $%^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...