>>> create cursor po ; >>> ( po_id I, ; >>> po_vendor c(30), ; >>> po_date D, ; >>> po_amount Y ; >>> ) >>> >>> insert into po values (1, 'UT', date(), $100) >>> insert into po values (2, 'Google', date()+1, $200) >>> >>> insert into po values (3, 'Microsoft', date()+2, $200) >>> >>> create cursor invoice ; >>> ( inv_id I, ; >>> inv_po_id I, ; >>> inv_Freight Y, ; >>> inv_SalesTax Y ; >>> ) >>> >>> insert into invoice values(1, 1, $20, $20) >>> insert into invoice values(2, 1, $20, $20) >>> >>> >>> insert into invoice values(3, 2, $20, $20) >>> insert into invoice values(4, 2, $30, $30) >>> >>> >>> >>> select ; >>> po_id, ; >>> po_vendor, ; >>> po_date, ; >>> po_amount, ; >>> nvl(po_Freight, $0) as po_Freight, ; >>> nvl(po_SalesTax, $0) as po_SalesTax; >>> from po ; >>> left join ; >>> ( select ; >>> inv_po_id, ; >>> sum(inv_Freight) as po_Freight, ; >>> sum(inv_SalesTax) as po_SalesTax ; >>> from invoice ; >>> group by 1 ; >>> ) X; >>> on ( po_id == inv_po_id) >>>>>
> po_needed = 3 > > > select ; > po_id, ; > po_vendor, ; > po_date, ; > po_amount, ; > nvl(po_Freight, $0) as po_Freight, ; > nvl(po_SalesTax, $0) as po_SalesTax ; > from po ; > left join ; > ( select ; > inv_po_id, ; > sum(inv_Freight) as po_Freight, ; > sum(inv_SalesTax) as po_SalesTax ; > from invoice ; > where ( inv_po_id == ?po_needed ) ; > group by 1 ; > ) X ; > on ( po_id == inv_po_id) ; > where ( po_id == ?po_needed ) ; > >First, thank you. Also, do I understand that this is an example of view that can to be created in SQL Server and not in VFP, right?