Sivasan
asked on
How to create a if condition on Ms access querry
Hi There,
I'm creating a query in access which I use for my Vb .net program.
One of the field in the query is a sum of the Weight field. I would like to create another field on the run called
Carrier - which is based on the sum of the weight field.
if the weight in > 3000 then I want it to be truckload else fed ex.
I also got in to the sql view from the access query and tried the Case statement, but gives me a systex error.
I have attached the Sql view of the query
SELECT DISTINCTROW one2.cus_no, one2.cus_alt_adr_cd, one2.loc, one2.[FINAL DATE], one2.[REQ DATE], one2.hold_fg, one2.oe_po_no, one2.[WO #], one2.status, one2.ORDATE, one2.cus_name, one2.FRT, one2.note_1, one2.note_2, one2.note_3, one2.note_4, one2.note_5, one2.ship_instruction_1, one2.ship_instruction_2, one2.[DEAD DATE], Sum(one2.qty_bkord) AS [Sum Of qty_bkord], Sum(one2.qty_ordered) AS [Sum Of qty_ordered], Sum(one2.qty_to_ship) AS [Sum Of qty_to_ship], Max(one2.A4GLIdentity) AS [Max Of A4GLIdentity], Sum(one2.tot_qty_ordered) AS [Sum Of tot_qty_ordered], Sum(one2.tot_qty_shipped) AS [Sum Of tot_qty_shipped], Sum(one2.qty_allocated) AS [Sum Of qty_allocated], Sum(one2.WT) AS SumOfWT,
Case Sum (one2.WT)
When >= 3000 THEN 'Truck Load'
Else
'Fed ex'
End As [Carrier Info]
FROM one2
GROUP BY one2.cus_no, one2.cus_alt_adr_cd, one2.loc, one2.[FINAL DATE], one2.[REQ DATE], one2.hold_fg, one2.oe_po_no, one2.[WO #], one2.status, one2.ORDATE, one2.cus_name, one2.FRT, one2.note_1, one2.note_2, one2.note_3, one2.note_4, one2.note_5, one2.ship_instruction_1, one2.ship_instruction_2, one2.[DEAD DATE];
I will appreciate any help.
Thanks
I'm creating a query in access which I use for my Vb .net program.
One of the field in the query is a sum of the Weight field. I would like to create another field on the run called
Carrier - which is based on the sum of the weight field.
if the weight in > 3000 then I want it to be truckload else fed ex.
I also got in to the sql view from the access query and tried the Case statement, but gives me a systex error.
I have attached the Sql view of the query
SELECT DISTINCTROW one2.cus_no, one2.cus_alt_adr_cd, one2.loc, one2.[FINAL DATE], one2.[REQ DATE], one2.hold_fg, one2.oe_po_no, one2.[WO #], one2.status, one2.ORDATE, one2.cus_name, one2.FRT, one2.note_1, one2.note_2, one2.note_3, one2.note_4, one2.note_5, one2.ship_instruction_1, one2.ship_instruction_2, one2.[DEAD DATE], Sum(one2.qty_bkord) AS [Sum Of qty_bkord], Sum(one2.qty_ordered) AS [Sum Of qty_ordered], Sum(one2.qty_to_ship) AS [Sum Of qty_to_ship], Max(one2.A4GLIdentity) AS [Max Of A4GLIdentity], Sum(one2.tot_qty_ordered) AS [Sum Of tot_qty_ordered], Sum(one2.tot_qty_shipped) AS [Sum Of tot_qty_shipped], Sum(one2.qty_allocated) AS [Sum Of qty_allocated], Sum(one2.WT) AS SumOfWT,
Case Sum (one2.WT)
When >= 3000 THEN 'Truck Load'
Else
'Fed ex'
End As [Carrier Info]
FROM one2
GROUP BY one2.cus_no, one2.cus_alt_adr_cd, one2.loc, one2.[FINAL DATE], one2.[REQ DATE], one2.hold_fg, one2.oe_po_no, one2.[WO #], one2.status, one2.ORDATE, one2.cus_name, one2.FRT, one2.note_1, one2.note_2, one2.note_3, one2.note_4, one2.note_5, one2.ship_instruction_1, one2.ship_instruction_2, one2.[DEAD DATE];
I will appreciate any help.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER