|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How tu use "for select" to obtain a temporary table
I have this table:
f1 f2 f3 5606 1 111111 5607 1 222222 5608 1 333333 5609 1 444444 5606 2 555555 5607 2 666666 5608 2 777777 and I need to obtain : f1_a f1_b f2 f3_a f3_b f3_a - f3_b 5606 5607 1 111111 222222 -111111 5606 5608 1 111111 333333 -222222 5606 5609 1 111111 444444 -333333 5607 5608 1 222222 333333 -111111 5607 5609 1 222222 444444 -222222 5608 5609 1 333333 444444 -111111 5606 5607 2 555555 666666 -111111 5606 5608 2 555555 777777 -222222 5607 5608 2 666666 777777 -111111 For each f2, each f1 is paired with each subsequent and the value reported into f3 can be compared. (the value reported into f3 are only as example, they will be different ) (ps: from a statistical point of view, I need to obtain the combinations) # vbaRstat # |
|
#2
|
||||
|
||||
|
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
|
#3
|
|||
|
|||
|
Quote:
The cartesian procudt is what I want but the table I'm using is big. But probably I'm not very able to develop query with a good performance. For example, I have a a table with 700.000 records composed in this way: tb1(cust_no1, cust_no2, cod_quality, data_cuple). I have another table: tb2(cust_no, cod_quality, value) with about 200.000 records. What I need is: SELECT A.cust_no1, A.cust_no2, A.cod_quality, A.data_cuple, B.value, C.value FROM (TB1 A LEFT JOIN TB2 B ON (A.CUST_NO1=B.CUST_NO AND A.COD_QUALITY=B.COD_QUALITY)) LEFT JOIN TB2 C ON (A.CUST_NO2=C.CUST_NO AND A.COD_QUALITY=C.COD_QUALITY) The result should be a table with at most 700.000 records, but the query it's too slow (more than 4 minutes, it's strange or it's the normality?). I have deloped the same database in Access, with the same table and records and I obtain the result in at most 1 minute. But Firebird is not efficient with left join?......:-).....but I think that the result of the query depends on my capability (very poor) in firebird.....(the db in firebird, however, is based on indices, and I don't understand where is the problem). So I thought that a procedure with a For select could be a solution to reduce the number of records to "fetch". Some comments? thanks a lot # vbaRstat # |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > How tu use "for select" to obtain a temporary table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|