I have the following SQL code: I use a WHERE block with a date interval. My problem is that I only want the interval of the date used on a particular part of the selection statement.
I want to limit that volume on DATE to my Internet Inneriod and Profit Initiative and other columns are not selected (Lines.Item, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.Allocated, Inventorry. CostPrice, Brand & StockStatus).
Do I need to bring data into 2 separate SQL queries or can I limit my date segment to only one part of the selected statement?
Select lines.Item, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.Allocated, Inventory.CostPrice, SUM (lines.Invoiced) * 1-In the form of QtySoldInPeriod, (sum lines.AmountBase-lines.CostAmount)) * - 1 as ProfitInPeriod, (vInventoryOptional2Values.Value, '/' ', include') place brand, inner lines as Inventory.Optional3 StockStatus which lists lines On. Item = Inventory. Include Inventory.O on Item Inventory ptional2 = vInventoryOptional2Values.RecordID Where Inventory.Item = 'Item #' and Lines.Date & gt; = 'Date' and Lines.Date & lt; = 'Date' and lines.Invoiced & LT; 0 more Inventory.Status = 0 and Inventory.option3 & lt; & Gt; 3 Group Lines.Item, Inventory.Optional3, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.CostPrice, when vInventoryOptional2Values.Value, yoga (lines.AmountBase-lines.CostAmount) of & lt Inventory.Allocated; 0
Edit: I've tried with a sub-query, but it can not be found to work:
SELECT lines Item, Inventory.ItemAnal, Inventory.OnHandPhys, Inventory.Allocated, Inventory.CostPrice ,, place (vInventoryOptional2Values.Value, '/', '') as the brand as Inventory.Optional3 StockStatus in (select sum ( Lines.Invoiced) * - 1 QtySoldInPeriod form (lines .item where lines.Date> gt; = '2014-01-01' and Lines.Date & lt; = '2014-01-31')) lines from inner lines Combine list = inventory.item on the basis of .item, include vInventoryOptional2Values on the inner list .op Type 2 = vInventoryOptional2Values.RecordID where inventory.ITIM = 'A158W' and lines Explore & lt; 0 more Inventory.Status = 0 and Inventory.option3 & lt; & Gt; Lines.Item, Inventory.Optional3, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.CostPrice, vInventoryOptional2Values.Value, 3 group by Inventory.Allocated
You should use the subquery and the updated question in your syntax is incorrect, try to use,
select lines.Item, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.Allocated, Inventory.CostPrice, (vInventoryOptional2Values.Value, select '/', '') as a brand, as Inventory.Optional3 StockStatus, (sum (l.Invoiced ) * 1-place lines from L ou L. Date> = '2014-01-01' and Include l.Date & lt; = '2014-01-31' and l.Item = lines.Item) QtySoldInPeriod as lines on lines.item = Inventory.item insider Prmvirviyovasnl on INNER inventory from which list 2 Valuyan. Optional 2 = vInventoryOptional2Values.Record ID where Inventory.Item = 'A158W' and lines Explore & lt; 0 more Inventory.Status = 0 and Inventory.option3 & lt; & Gt; 3 Group Lines.Item, Inventory.Optional3, Inventory.ItemAlternative, Inventory.OnHandPhys, Inventory.CostPrice, vInventoryOptional2Values.Value, Inventory.Allocated
No comments:
Post a Comment