# Miscellaneous > Structured Query Language (SQL) >  sql query   releatıon record show and sub total and grand total thank you for your

## howerlover

stock    table 
fkod      sno       sy1      sy2                 sy3       sy4

CL0        1         980                           0
cl0        2         980                           1
CL1        1         920                           1
CL1        2         920                           1
CL1        1         980 01.01.2011                1        5,5
CL1        2         980 01.01.2011                1         1
CL1        3         980 01.01.2011                1         1
CL1        4         980 01.02.2011                1         1
CL1        5         980 01.01.2011                1         1
CL1        6         980 01.01.2011                1         1
CL1        7         980 01.01.2011                1         1
CL1        8         980 01.01.2011                1         1
CL1        9         980                           1         1
CL1        10        980                           1         1
CL1        11        980                           1         1
CL1        12        980                           1         1


fkod =firm code
sno = record number
sy1=stock code
sy2= date
sy3=weight code
sy4= one code
                    index key= fkod+sy1+sno   
         --------------- up  my table data and datastructure

ı want under figure  apear seeming list ı write sql1=....

but ı cant  result it  how ı can wrıte  result 


        ı suppose under the syntax wrong how  ı can sql1=........

 sql1 = "select fkod ,sy1 from stok WHERE fkod order BY fkod,sy1 in (select fkod,sy1,sum(sy3) as sy33,sum(sy4) as sy44 from stok WHERE fkod GROUP BY fkod,sy1)"

Do While Not sorgu1.EOF
 scmb.AddItem sorgu1!fkod & " -" & sorgu1!sy1
 sorgu1.MoveNext
Loop 


HOW I CAN WRITE  UNDER THE  RESULT SELECT SYNTAX 
                        R   E  S   U  L  T  AREA UNDER THE FIGURE

fkod      sno       sy1      sy2                 sy3       sy4 

CL0        1         980                             1           0
cl0        2         980                              0           1
                                          sub tot     1           1 
CL1        1         920                             1           0
CL1        2         920                             1           0
                                      sub tot          2           0
CL1        1         980 01.01.2011              1          5,5
CL1        2         980 01.01.2011              1           1
CL1        3         980 01.01.2011              1           1
CL1        4         980 01.02.2011              1           1
CL1        5         980 01.01.2011              1           1
CL1        6         980 01.01.2011              1           1
CL1        7         980 01.01.2011              1           1
CL1        8         980 01.01.2011              1           1
CL1        10        980                             1           1            
CL1        11        980                             1           1
CL1        12        980                             1           1
                                        sub tot        11         15.5
                                grand total           14         16.5

----------

