DBExpress Mestre Detalhe
Faço utilizando os componentes dbexpress um mestre X detalhe. Só que no detalhe tenho um select que pega um parâmetro e uns dois subselects que pega o mesmo parâmetro. Na hora que abro o mestre ele passa aspenas o parametro para o select e não para os dois subselects. Como faço para ele passar o mesmo parametro para os tres??? Abaixo o meu select:
SELECT coun.Sf_Id, sta.Sf_Desc,half.usv_id,
(SELECT SUM(cou.Uc_Quantity)
FROM Ufp_Counters cou INNER JOIN
GetOnTypes geton ON cou.Got_Id = geton.Got_Id INNER JOIN
Ufp_HalfTrips hal ON (hal.Uht_Id = cou.Uht_Id)
WHERE (geton.Got_Id = 0) AND (cou.Uc_NoCredit = 0) AND (cou.sf_id = coun.sf_id) AND (hal.usv_id=:Usv_Id)) AS TotalNormal,
(SELECT SUM(cou.Uc_Quantity)
FROM Ufp_Counters cou INNER JOIN
GetOnTypes geton ON cou.Got_Id = geton.Got_Id INNER JOIN
Ufp_HalfTrips hal ON (hal.Uht_Id = cou.Uht_Id)
WHERE (geton.Got_Id = 1) AND (cou.Uc_NoCredit = 0) AND (cou.sf_id = coun.sf_id) AND (hal.usv_id=:Usv_Id) ) AS TotalTemporal
FROM Ufp_HalfTrips half INNER JOIN
Ufp_Counters coun ON half.Uht_Id = coun.Uht_Id INNER JOIN StatisticalFamilies sta ON coun.Sf_Id = sta.Sf_Id
where half.Usv_Id = :Usv_Id
GROUP BY coun.Sf_Id, sta.Sf_Desc,half.usv_id
ORDER BY coun.Sf_Id
SELECT coun.Sf_Id, sta.Sf_Desc,half.usv_id,
(SELECT SUM(cou.Uc_Quantity)
FROM Ufp_Counters cou INNER JOIN
GetOnTypes geton ON cou.Got_Id = geton.Got_Id INNER JOIN
Ufp_HalfTrips hal ON (hal.Uht_Id = cou.Uht_Id)
WHERE (geton.Got_Id = 0) AND (cou.Uc_NoCredit = 0) AND (cou.sf_id = coun.sf_id) AND (hal.usv_id=:Usv_Id)) AS TotalNormal,
(SELECT SUM(cou.Uc_Quantity)
FROM Ufp_Counters cou INNER JOIN
GetOnTypes geton ON cou.Got_Id = geton.Got_Id INNER JOIN
Ufp_HalfTrips hal ON (hal.Uht_Id = cou.Uht_Id)
WHERE (geton.Got_Id = 1) AND (cou.Uc_NoCredit = 0) AND (cou.sf_id = coun.sf_id) AND (hal.usv_id=:Usv_Id) ) AS TotalTemporal
FROM Ufp_HalfTrips half INNER JOIN
Ufp_Counters coun ON half.Uht_Id = coun.Uht_Id INNER JOIN StatisticalFamilies sta ON coun.Sf_Id = sta.Sf_Id
where half.Usv_Id = :Usv_Id
GROUP BY coun.Sf_Id, sta.Sf_Desc,half.usv_id
ORDER BY coun.Sf_Id
Foxcyber
Curtidas 0