Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need information to pull data from a SQL database.
I've never worked with SQL, and the computer company where I have to extract the data does not make me much attention.
The code associated with the company delegation will be located in the parameter table for enterprise delegation (ridppar where ridppar.cod_ent = rid.cod_ent AND ridppar.cod_del = rid.cod_del AND ridppar.cod_param = 2421)
Each company / delegation to treat stocks will locate the item (ridel where ridel.cod_ent = rid.cod_ent AND ridel.cod_del = rid.cod_del), but only the articles that are published on the Group (ridel.char8_al = "S "), and accumulate their stocks available and publishable. The stock is equal to the stock publishable available (ridel.sre_art - ridel.crs_art), but considering only the publishable percentage (ridel.dec4_al), and adjusting the minimum limits (ridel.dec5_al) and maximum (ridel.dec6_al), if these are reported.
In addition to the above details, also extract the selling price of the article that will be offered to members of the group. This information will be extracted from the rate table sales (tvl), namely a rate previously be preset in parameter 2422 (ridpparwhere ridppar.cod_ent = rid.cod_ent AND ridppar.cod_del = rid.cod_del AND ridppar.cod_param = 2422).
Only be exported items have a greater than zero stock available and priced sales rate preset in parameter 2422.
These are the fields I need to get
tvl.cod_tav = int(ridppar.val_param) AND
tvl.art_amb = artic.art_amb AND
tvl.cod_art = artic.cod_art AND
tvl.cod_sas = “EUR” AND
tvl.can_tvl = 0 AND
tvl.cod_uea = ridel.cod_uea_st
tvl.cod_tav = int(ridppar.val_param) AND
tvl.art_amb = artic.art_amb AND
tvl.cod_art = artic.cod_art AND
tvl.cod_sas = “EUR” AND
tvl.can_tvl = 0 AND
tvl.cod_uea = ridel.cod_uea_st
prove.cod_pro = ridel.cod_pro
This line doesn't make sense: prove.cif_pro--------------- prove where prove.pro_amb = prove.pro_amb
I suspect one of the prove.pro_amb is supposed to be some other field. You'll have to add the correct line to the where clauses.
If the sql statement below doesn't work, start with one table and build it a table at a time.
SELECT
artic.ref_art,
artic.ctl_art,
artic.dep_art,
galmarca.nom_mar,
prove.cif_pro,
prove.raz_pro,
ridel.cod_art,
ridel.cod_uea_st,
tvl.cuea_tvl,
tvl.cuea_tvl,
tvl.pre_tvl
FROM
artic,
galmarca,
prove,
ridel,
ridpar,
tvl
WHERE
artic.art_amb = ridel.art_amb AND
artic.cod_art = ridel.cod_art AND
galmarca.cod_mar = artic.mar_art AND
prove.cod_pro = ridel.cod_pro AND
tvl.cve_amb = rid.cve_amb AND
tvl.cod_tav = int(ridppar.val_param) AND
tvl.art_amb = artic.art_amb AND
tvl.cod_art = artic.cod_art AND
tvl.cod_sas = "EUR" AND
tvl.can_tvl = 0 AND
tvl.cod_uea = ridel.cod_uea_st
In case the above doesn't work:
Step one, start with just one table:
SELECT
artic.ref_art,
artic.ctl_art,
artic.dep_art
FROM
artic
WHERE
artic.art_amb = ridel.art_amb AND
artic.cod_art = ridel.cod_art
Step two, we add a second table:
SELECT
artic.ref_art,
artic.ctl_art,
artic.dep_art,
galmarca.nom_mar
FROM
artic,
galmarca
WHERE
artic.art_amb = ridel.art_amb AND
artic.cod_art = ridel.cod_art AND
galmarca.cod_mar = artic.mar_art
etc...
Thank you for your prompt response.
I will try and I commented!
hi, again i tried the first select that you do, but no working good,
and now i am trying select step by step.
it works, at first level but when i add table tvl. i think it do a bad relationship create 300.000.000 line.. something no work well
Without knowledge of the database schema this is going to be very difficult to solve. What you can try is load a limited set of data from each table into qlikview separately. If the database supports the TOP statement you can do: select top 100 * from artic
For oracle databases you can use this: select * from artic where rowno < 100
That way you can see what fields each table has and figure out on what fields the tables should be joined. Once you know that you can try to construct the correct sql statement to get the data you need with only one sql statement.
That´s a good idea, i will trie with this..
Thanks a lot for all.