Projection is used to vertically filter and select columns in a table.The Selection operation can be used to filter rows that satisfy a certain condition in a table.
program learn
implicit none
integer,dimension(2,3)::a
integer,dimension(2,3)::b
integer,dimension(24)::c
integer,dimension(4,6)::d
integer::i,j
integer::k
a=reshape([1,2,66,89,74,79],[2,3],order=[1,2])
b=reshape([1,2,76,99,84,59],[2,3],order=[1,2])
write (*,120) 'aid','a1','a2','bid','b1','b2'
c=[((a(i,:),b(j,:),i=1,2),j=1,2)]
d=reshape(c,[4,6],order=[2,1])
write (*,110) c
write (*,*) "---------"
write (*,110) d(2,:)
write (*,*) "---------"
write (*,110) d(:,2)
write (*,*) "---------"
write (*,*) "b1>70 and a2<70"
write (*,120) 'aid','a1','a2','bid','b1','b2'
!b1>70 and a2<90 Selection
k=1
do
if (d(k,5)>70 .and. d(k,3)<79) write (*,110) d(k,:)
k=k+1
if (k>4) exit
end do
write (*,120) 'aid','a1','a2','bid','b1','b2'
!b1>70 and a2<90 Projection and Selection
write (*,*) "b1>70 and a2<70 and aid=bid"
write (*,120) 'aid','a1','a2','b1','b2'
k=1
do
if (d(k,5)>70 .and. d(k,3)<79 .and. d(k,1)==d(k,4)) write (*,110) d(k,1:3),d(k,5:6)
k=k+1
if (k>4) exit
end do
110 format (6(I3))
120 format (6(A3))
end program learn
Top comments (0)