Hello Techie,
i came across very unique situation
I need to write sql code which perform Division on column i.e (Per Car Quantity = Cylinders/Description)
Per Car Quantity contain some different value other than the calculation, then those records
be in output.
description quantity should be the very last string seperated by semicolon
but the real problem are data in column
- data in description given as OE Replacement; seven-- 7 in words sometime
and sometime in numeric form - if data in two column are not even something like 15/7 then i need to round up to 2
then need to check whether 2 present in Per Car Quantity
can anyone please suggest something if its possible in SQL
DECLARE @MYTABLE TABLE
(
Make VARCHAR (100),
Model VARCHAR (100),
Year VARCHAR (100),
Cylinders VARCHAR (100),
[Description] VARCHAR (100),
PER VARCHAR (100),
[Remarks=Is Per Car Quantity = Cylinders/Description] VARCHAR (500)
)
INSERT into @MYTABLE
SELECT 'Cadillac', 'DeVille', '1982', '15', 'OE Replacement; seven', '1', 'SHOULD BE IN OUTPUT BECAUSE 15/7 IS 2.14 but PER CAR QUANTITY IS 1 HERE' union all
SELECT 'SUZU', 'MSTAR', '2006', '6', 'OE Replacement; Single', '2', 'SHOULD BE IN OUTPUT BECAUSE 6/1 IS 6 but PER CAR QUANTITY IS 2' union all
SELECT 'FORD', 'FEISTA', '1991', '8', 'OE Replacement; Set Of 8', '1', 'ITS SHOULD EXCLUDE FROM OUTPUT because 8/8 IS 1 and PER CAR QUANTITY IS ALSO 1' union all
SELECT 'HONDA', 'CIVIC', '2005', '500', 'OE Replacement; FIFTY', '49', 'SHOULD BE IN OUTPUT BECAUSE 500/50 IS 10 but PER CAR QUANTITY IS 49' union all
SELECT 'BAJAJ', 'CHETAK', '2004', '15', 'OE Replacement; Set Of 3', '5', 'ITS SHOULD EXCLUDE FROM OUTPUT because 15/3 IS 5 and PER CAR QUANTITY IS ALSO 5'
select * from @MYTABLE
Thanks