Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CrossTab in T-SQL code
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
CrossTab in T-SQL code
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
Firebird
Divers
Thread ID:
01250107
Message ID:
01250107
Vues:
62
Hi all

I have the following tables:

mItem
iID, cCode

tRequisition
iID, iNo

sRequisitionItems
iID, iPID, iItemID, bQty

I would like to have something like this for SQL Pass Through:
SELECT tR.iNo, tR.cBk, mI.cCode, sR.bQty
   FROM tRequisitions tR
      JOIN sRequisitionItems sR ON sR.iPID = tR.iID
      JOIN mItems mI ON mI.iID = sR.iItemID
   WHERE tR.dDt BETWEEN ?vp_dFromDt AND ?vp_dToDt
   ORDER BY tR.iNo, tR.cBk, sR.iSrNo
but just one line for each requisition, with columns for each mI.cCode with it's respective SUM(sR.bQty) like below:

1, A, A4, 10, A3, 0, A0, 5, ...

Hope I have been able to explain my requirements. I guess I can CASE WHEN, but that makes the statement long, if there is an efficient way, which can help when newer mItems.cCodes are added.

Thanks.
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform