select * from Discount
select MAX(DiscountID) from DiscountTest
select MAX(Convert(int, substring(DiscountID, 4, 20))) as thismaxid from DiscountTest
select MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V',''))) as thismaxid from Discount
select GETDATE()
select DAY('2012-01-02') YYYY-MM-DD select DAY('01-02-2012') MM-DD-YYYY
SELECT SUBSTRING(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))),
(CHARINDEX('.', CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))+1),
LEN(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))) as thismaxid from discount
DECLARE @d DATETIME = GETDATE(); SELECT FORMAT(GETDATE())
SELECT MAX(Convert(float,REPLACE(substring( DiscountID,4, 20),'V',''))) as thismaxid from discount
select ( SELECT SUBSTRING(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))),
(CHARINDEX('.', CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))+1)
, LEN(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))) as thismaxid from discount) as themaxid1,
( select MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V',''))) as thismaxid from Discount ) as themaxid2
select
( select MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V',''))) as thismaxid from Discount ) as themaxid2,
(SELECT SUBSTRING(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))),
(CHARINDEX('.', CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))+1)
, LEN(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))) as thismaxid from discount) as themaxid1
select
( select MAX(CONVERT(FLOAT,Replace(SUBSTRING(DiscountID,5, 6), 'V',''))) as thismaxid from Discount ) as themaxid1,
(SELECT SUBSTRING(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))),
(CHARINDEX('.', CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))+1)
, LEN(CONVERT(varchar,MAX(Convert(float,REPLACE(substring(DiscountID,4, 20),'V','')))))) as thismaxid from discount) as themaxid2
No comments:
Post a Comment