Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2014
    Posts
    2

    Unanswered: Creating new variable using declare

    I'm new to SQL, and I'm trying to combine an inner join with the creation of a new variable from an existing one. whenever I run the code, I come up with an error 4856 (syntax). The code is below:

    create table user.tablename as
    select a.week, a.store, a.item, a.unit, a.cents, b.geography
    from user2.table1 as a inner join user2.table2 as b on a.store=b.store
    declare @cents int
    declare@dollars decimal(38,2)
    set @dollars=(@cents/100)

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I can't test your code without the schema and table definitions, but the only syntax errors I see are the missing semi-colons as statement terminators.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Apr 2014
    Posts
    2
    I should have mentioned that I'm working in Vertica, so no semicolons necessary. I think I have it figured out so that I can perform the calculation in my select statement instead, though. Thanks!

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by PDMUF View Post
    I should have mentioned that I'm working in Vertica, so no semicolons necessary.
    Yep, that would help!

    Glad you've got it working!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Feb 2012
    Posts
    44
    do you mean 'HP Vertica Analytics Platform'? That's not MySQL syntax?

    From Vertica Analytics Platform | Big Data Analytics

    HP Vertica Analytics Platform

    The HP Vertica Analytics Platform 7 “Crane” enables you to accelerate business value from a vastly expanded variety of data by simplifying the exploration and analysis of semi-structured and “dark data.” This release also includes the most comprehensive SQL on Hadoop, critical security and performance enhancements, and more.
    is SQL on Hadoop the same syntax like MySQL?

    just curious

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •