, Guest>> || || |
/ Microsoft SQL Server
    [new]
gerogekochkin
Member

:
: 93
, :
- , . , , ; , , , = 2; , , , = 4 .. - (). , .
:

. .
. .
. . . .
. .
19 14, 18:25[15905412]      |
 Re:   [new]
gerogekochkin
Member

:
: 93
gerogekochkin,
19 14, 18:25[15905413]      |
 Re:   [new]
gerogekochkin
Member

:
: 93
kod_sotr fam name otch date_rog date_rab kod_otdel kod_dolgn uvolen oklad parent_id
200000 1950-01-01 1988-02-01 98 25 10000.00 NULL
200061 1963-01-30 1995-01-02 16 8 1500.25 200309
200072 1939-08-28 1996-09-01 22 8 1500.25 200436
200081 1961-01-25 1996-09-01 16 20 3100.00 200402
200084 1951-12-05 1996-09-01 97 16 7000.00 200000
200160 1955-02-07 1995-05-01 50 10 3400.00 200420
200198 1949-07-28 1995-05-01 52 9 1200.50 200202
200202 1949-10-20 1995-05-01 52 12 5000.00 200000
200271 1941-06-04 1996-05-23 25 14 3400.00 200202
200276 1960-03-11 1996-09-01 92 22 2700.00 200297
200290 1949-10-20 1996-09-01 92 22 2700.00 200297
200297 1949-10-29 1995-11-18 92 2 3500.00 200000
200309 1948-10-07 1995-11-01 16 7 2500.00 200402
200314 1970-06-21 1996-02-01 92 18 2500.00 200297
200332 1969-12-18 1996-09-01 46 15 3700.00 200436
200351 1956-10-20 1996-05-23 25 14 3400.00 200202
200353 1950-04-01 1996-09-01 96 5 3700.00 200000
200368 1972-11-10 1995-09-01 29 5 3700.00 200000
200372 1949-07-28 1995-11-01 16 5 3700.00 200402
200379 1960-02-09 1995-09-01 46 15 3700.00 200436
200381 1963-08-29 1996-09-01 29 20 3100.00 200368
200382 1947-04-20 1996-01-01 29 20 3100.00 200368
200397 1973-09-30 1995-05-01 52 9 1200.50 200202
200402 1949-02-20 1996-09-01 16 16 7000.00 200000
200409 1946-12-11 1996-01-15 22 5 3400.00 200436
200414 1938-04-01 1996-09-01 96 5 3700.00 200353
200419 1971-12-22 1995-09-01 16 5 3700.00 200402
200420 1962-01-05 1995-05-01 50 13 5000.00 200000
200436 1974-08-29 1996-09-01 22 5 3700.00 200000
19 14, 18:28[15905423]      |
 Re:   [new]
gerogekochkin
Member

:
: 93
- , , . .

declare @kod_sotr int, @parent_id int, @parent_id1 int, @vlozh tinyint=0, @i tinyint=0, @fam varchar(30), @nad varchar(max)
declare @t table (vlozh int, fam varchar(30), nad varchar(max))
declare cur1 cursor
for select kod_sotr, parent_id from sotr

open cur1

fetch next from cur1 into @kod_sotr, @parent_id1

WHILE @@FETCH_STATUS = 0
	BEGIN
		set @fam=(select fam from sotr where kod_sotr=@kod_sotr)
		if @parent_id1 is null
			begin
				set @vlozh=0
				set @nad=''
			end
		else
			begin
				set @vlozh=0
				set @nad=''
				set @parent_id=@parent_id1
				while @parent_id is not null
					begin
						set @kod_sotr=( select kod_sotr from sotr where kod_sotr=@parent_id1)
						set @parent_id=( select parent_id from sotr where kod_sotr=@kod_sotr)
						set @parent_id1=( select parent_id from sotr where kod_sotr=@kod_sotr and parent_id is not null)
						set @vlozh=@vlozh+1
						set @nad=@nad+(select fam from sotr where kod_sotr=@kod_sotr)
					end
				
			end
	insert @t values( @vlozh, @fam, @nad)
	set @vlozh=0
	set @nad=''
	fetch next from cur1 into @kod_sotr, @parent_id1
	END
CLOSE cur1;
DEALLOCATE cur1;


select replicate ('.', vlozh*2)+fam from @t order by nad


: 19 14, 19:19
19 14, 18:30[15905427]      |
 Re:   [new]
gerogekochkin
Member

:
: 93
, , !
!
19 14, 18:31[15905429]      |
 Re:   [new]
igr_ok
Member

:
: 170
gerogekochkin
, , !
CTE
19 14, 19:09[15905540]      |
 Re:   [new]
gerogekochkin
Member

:
: 93
igr_ok, , !
19 14, 19:30[15905620]      |
/ Microsoft SQL Server