Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Using sub queries to MySQL
jfreak53
I need to use sub queries for a report I am making. For instance, table one has printout of this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select IdSC_Materia as Cod,Codigo,Nombre,ImprimirBoleta,Oficial,Hombre,Mujer,Mixto,PosicionCertificado,PosicionBoleta,PuntosGana,MateriaCompuesta from sc_materia where Activa=1 and IdSC_Grado=18</pre>
<br />
4 of those records have MateriaCompuesta marked as 1 instead of 0, which means they are composit records. So for those records, each one I have to run this one on:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select m.Codigo,m.Nombre,mt.Porcentaje from SC_Materia as m,SC_MateriaDetalle as mt where m.IdSC_Materia=mt.IdSC_Materia and mt.IdSC_MateriaPadre=1603</pre>
<br />
The "mt.IdSC_MateriaPadre=1603" is the code of each one of the marked as 1 records. So for each record I have to run that query and print out to table 2 under the category heading of query 1 record name. It prints like this attached file prints. Table one, then table two with headings from one and sub records from query two to each heading.<br />
<br />
How would I do these sub queries, since this is not the only report I have to do sub queries on?
Find more posts tagged with
Comments
mwilliams
You can make your first dataSet, group it by your main field, create another dataSet with '?' dataSet parameters in the query, add this table into your first table's group footer, select this new table, click the dataSet binding parameters button in the binding tab of the property editor, and assign the values from your outer table that you need for your inner query parameters to your dataSet parameters here. If I'm understanding correctly, that should do it. Let me know if you have questions or need an example. There should be examples like this in the devShare already. If you can't find one or this doesn't help, let me know.
jfreak53
Wonderful!! Works like a charm!
Thanks for the help, it took me a while to figure out the grouping and param on query, but once I did, sweet! I will give this a try on my other reports that have something similar and see if I can get them working.
Thanks again for all the help.
mwilliams
You're very welcome. Sorry if my explanation was a bit confusing!