Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End sql help

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #29653
    cybershot
    Participant

    I am trying to write a query that will add a dollar sign onto the values in the ExtendedPrice field. This is a working query

    SELECT FK_PONBR AS ‘Part Numbers’,
    Quantity AS ‘Part Quantity’,
    ExtendedPrice
    FROM PO_LINE_ITEM

    I am working in Microsoft SQL Server Management Studio Express.

    How do I add a $ sign?

    #79932
    Rob MacKay
    Participant

    As you are pulling the data is there any reason why you can not do it when you echo out the data? Just if you have the data and you are using PHP for example you can just add the dollar sign then… ?

    #80036
    cybershot
    Participant

    yes, the reason that I am not doing it in php is that I want to know how to do it in sql

    #79788
    Rob MacKay
    Participant

    Well the thing is I don’t think you can when selecting data and I don’t really see the benefit of doing it anyway? Is there something I am missing?

    #80071
    dcp3450
    Participant

    simply. you can’t do that with sql. adding a $ in sql causes it to look at the item as a variable found in php ($name). it assumes it’s a variable since the $ is not a default special character such as %.

    #80108
    cybershot
    Participant

    I am doing the work in Microsoft sql server 2005. Not using php at all. Just putting in queries and returning results. No php is being used. I posted the topic here because this forum is the closest to sql. I think there is a way to do it. I just can’t make it work.

    #80096
    Rob MacKay
    Participant

    I would definitely be interested to know if there is a way… :)

    #80113
    dcp3450
    Participant
    #80116
    Rob MacKay
    Participant

    best file name ever.

    adollarsignisanotheranchoringoperatorandmatchesonlytheendofastring.htm

    Hahaha

    #80298
    cybershot
    Participant

    this query added the dollar sign to the money

    SELECT ‘$’ + CONVERT(CHAR(5), cost, 0)
    FROM PART;

    I had to convert the results of the cost column and the zero means to add two decimal places. This is what the query returned

    $0.59
    $0.66
    $5.77
    $6.12
    $0.88
    $0.94
    $0.74
    $2.09
    $1.87
    $1.96
    $3.55
    $3.65
    $3.58

    #80314
    Rob MacKay
    Participant

    Awesome! :D nice find!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘Back End’ is closed to new topics and replies.