Click here to Skip to main content
15,896,453 members
Home / Discussions / Database
   

Database

 
GeneralRe: How can we Empty the whole tables by one single query Pin
_Damian S_3-Nov-09 19:23
professional_Damian S_3-Nov-09 19:23 
GeneralRe: How can we Empty the whole tables by one single query Pin
J4amieC3-Nov-09 23:52
J4amieC3-Nov-09 23:52 
GeneralRe: How can we Empty the whole tables by one single query Pin
Ashfield4-Nov-09 7:31
Ashfield4-Nov-09 7:31 
QuestionSSRS - web service interface generated pdf's with slightly different font/color Pin
devvvy3-Nov-09 0:46
devvvy3-Nov-09 0:46 
QuestionTable could not found Pin
haleemasher2-Nov-09 22:33
haleemasher2-Nov-09 22:33 
AnswerRe: Table could not found Pin
Niladri_Biswas2-Nov-09 23:55
Niladri_Biswas2-Nov-09 23:55 
Questionneed latest records Pin
Member 38798812-Nov-09 18:23
Member 38798812-Nov-09 18:23 
AnswerRe: need latest records Pin
Niladri_Biswas2-Nov-09 19:34
Niladri_Biswas2-Nov-09 19:34 
Try this

declare @tblMaster table(pid int primary key,name varchar(20))
insert into @tblMaster
select 1,'m1' union all select 2,'m2' union all
select 3,'m3' union all select 4,'m4' union all
select 5,'m5' union all select 6,'m6'

declare @tblChild table(cid int primary key,pid int,name varchar(20))
insert into @tblChild
select 1,2,'nm1' union all select 2,2,'nm2' union all
select 3,1,'nm3' union all select 4,5,'nm4' union all
select 5,6,'nm5'

select pid,cid,name from
(
select 
	m.pid
	,c.cid
	,case when c.name IS null then m.name
		else c.name 
	end name
	,row_number() over(partition by m.pid order by c.name desc) as rn 

from @tblChild c
full join @tblMaster m
on  c.pid = m.pid
)x(pid,cid,name,rn)
where rn = 1
order by  pid desc

Smile | :)

Niladri Biswas

GeneralRe: need latest records Pin
Member 38798812-Nov-09 19:49
Member 38798812-Nov-09 19:49 
GeneralRe: need latest records Pin
Niladri_Biswas2-Nov-09 20:11
Niladri_Biswas2-Nov-09 20:11 
AnswerRe: need latest records Pin
Ashfield2-Nov-09 21:10
Ashfield2-Nov-09 21:10 
QuestionNOT EXISTS function not working Pin
Bomb_shell2-Nov-09 11:54
Bomb_shell2-Nov-09 11:54 
AnswerRe: NOT EXISTS function not working Pin
Mycroft Holmes2-Nov-09 13:59
professionalMycroft Holmes2-Nov-09 13:59 
GeneralRe: NOT EXISTS function not working Pin
Bomb_shell3-Nov-09 10:47
Bomb_shell3-Nov-09 10:47 
AnswerRe: NOT EXISTS function not working Pin
Niladri_Biswas2-Nov-09 16:46
Niladri_Biswas2-Nov-09 16:46 
AnswerRe: NOT EXISTS function not working Pin
Niladri_Biswas2-Nov-09 19:41
Niladri_Biswas2-Nov-09 19:41 
AnswerRe: NOT EXISTS function not working Pin
Ashfield2-Nov-09 21:01
Ashfield2-Nov-09 21:01 
QuestionHow to make unique, readable, varchar codes in a Guid ID table Pin
Sir Dot Net2-Nov-09 11:35
Sir Dot Net2-Nov-09 11:35 
AnswerRe: How to make unique, readable, varchar codes in a Guid ID table Pin
Mycroft Holmes2-Nov-09 13:53
professionalMycroft Holmes2-Nov-09 13:53 
AnswerRe: How to make unique, readable, varchar codes in a Guid ID table Pin
εїзεїзεїз2-Nov-09 20:51
εїзεїзεїз2-Nov-09 20:51 
Questionhow to write querey return the unique CustomerId with the first CustomerName ? Pin
AJ Hoge1-Nov-09 23:49
AJ Hoge1-Nov-09 23:49 
AnswerRe: how to write querey return the unique CustomerId with the first CustomerName ? Pin
il_masacratore2-Nov-09 0:32
il_masacratore2-Nov-09 0:32 
GeneralRe: how to write querey return the unique CustomerId with the first CustomerName ? Pin
AJ Hoge2-Nov-09 4:42
AJ Hoge2-Nov-09 4:42 
AnswerRe: how to write querey return the unique CustomerId with the first CustomerName ? Pin
J4amieC2-Nov-09 1:18
J4amieC2-Nov-09 1:18 
GeneralRe: how to write querey return the unique CustomerId with the first CustomerName ? Pin
AJ Hoge2-Nov-09 4:51
AJ Hoge2-Nov-09 4:51 

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.