Home Forums SQL Server 2012 SQL 2012 - General how to properly write this syntax? case when statement with dates RE: how to properly write this syntax? case when statement with dates

  • dandenise316 (6/29/2015)


    DROP TABLE mytable;

    CREATE TABLE mytable(

    primary_attribute_value VARCHAR(33) NOT NULL PRIMARY KEY

    , date VARCHAR(27) NOT NULL

    , emails INTEGER(3) NOT NULL

    , emails_delivered INTEGER(3) NOT NULL

    , delivery_rate NUMERIC(6,4) NOT NULL

    , opens INTEGER(2) NOT NULL

    , open_rate NUMERIC(6,4) NOT NULL

    , iphone INTEGER(2) NOT NULL

    , android INTEGER(1) NOT NULL

    , pc INTEGER(2) NOT NULL

    , unsubscribes BIT NOT NULL

    , clicks INTEGER(2) NOT NULL

    , responses BIT NOT NULL

    , opps INTEGER(1) NOT NULL

    , approvals_delivered BIT NOT NULL

    , approvals_opened BIT NOT NULL

    , loans_delivered BIT NOT NULL

    , draw_amount NUMERIC(14,6)

    );

    INSERT INTO mytable(primary_attribute_value,date,emails,emails_delivered,delivery_rate,opens,open_rate,iphone,android,pc,unsubscribes,clicks,responses,opps,approvals_delivered,approvals_opened,loans_delivered,draw_amount) VALUES ('6/23 CLI - Yodlee.Email','2015-06-22T00:00:00.0000000',147,144,0.9795,67,0.4652,19,9,55,0,28,0,5,0,0,0,2997433.117148);

    INSERT INTO mytable(primary_attribute_value,date,emails,emails_delivered,delivery_rate,opens,open_rate,iphone,android,pc,unsubscribes,clicks,responses,opps,approvals_delivered,approvals_opened,loans_delivered,draw_amount) VALUES ('LOC Rate Decrease June 2015.Email','2015-06-22T00:00:00.0000000',112,109,0.9732,52,0.4770,27,7,10,0,4,0,0,0,0,0,NULL);

    Are you sure you're using SQL Server ? The integer data type does not use any kind of length parameter. Also, why are you using VARCHAR(27) for a datetime value? Any chance you're data is coming from Oracle? If that's true, there might not be much we can help with here. This is a SQL Server forum.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)