Select $ (Dollar Sign)

SELECT $ (dollar sign)

When SQL Server comes across your $ sign, it automatically converts it into a money data type. Because you don't have an explicit value after the dollar sign, SQL Server is assuming 0.00. From MSDN:

When converting to money or smallmoney, integers are assumed to be monetary units. For example, the integer value of 4 is converted to the money equivalent of 4 dollars (for us_english, the default language). Numbers to the right of the decimal in floating-point values are rounded to four decimal places for money values. Expressions of data types char or varchar that are being converted to an integer data type must consist only of digits and an optional plus or minus sign (+ or -). Leading blanks are ignored. Expressions of data types char or varchar converted to money can also include an optional decimal point and leading dollar sign ($).

Adding a dollar sign in front of currency

There are way more subqueries than are needed.

Also, if the name column in fruit is not unique, the query has the potential to throw a "too many rows" error.

If name='apple' can match more than one row in fruit, we might want something like this:

 SELECT f.fruitid
, f.name
, SUM( f.price * i.quantity ) AS `total value`
, CONCAT('$', SUM( f.price * i.quantity ) ) AS `dollar total value`
FROM fruit f
LEFT
JOIN inventory i
ON f.fruitid = i.fruitid
WHERE f.name = 'apple'
GROUP
BY f.fruitid

If we want a combined value of all fruit that match, then something like this:

 SELECT SUM( f.price * i.quantity ) AS `total value`
, CONCAT('$', SUM( f.price * i.quantity ) ) AS `dollar total value`
FROM fruit f
LEFT
JOIN inventory i
ON f.fruitid = i.fruitid
WHERE f.name IN ('apple','pear','pineapple')

This doesn't address formatting to two decimal places. If we want a formatted value to two decimal places and including thousands separators, we could make use of the MySQL FORMAT function.

What does the dollar sign ('$') mean when in the string to .query?

Pretty universally in that context it's called a "placeholder". You got that code from this blog entry. You can see there that client is defined above in the callback to pg.connect,

pg.connect(connectionString, (err, client, done) => {

Looking up in that blog entry, pg is defined here

const pg = require('pg');

You can always find out what an npm-installed module name resolves to by doing a quick search. In this case though the blog openly says they're using node-postgres. Which documents this under,

  • Paramaterized Queries

Paramaterized means accepting of a parameter. That parameter's placement is defined with a "placeholder" as specified with $. The purpose of this is often to save time in planning and to avert SQL Injection attacks.

What is the purpose of the dollar sign in JavaScript?

A '$' in a variable means nothing special to the interpreter, much like an underscore.

From what I've seen, many people using jQuery (which is what your example code looks like to me) tend to prefix variables that contain a jQuery object with a $ so that they are easily identified and not mixed up with, say, integers.

The dollar sign function $() in jQuery is a library function that is frequently used, so a short name is desirable.

ORACLE SQL - How to add commas and dollar sign to a table value

This nature can be derived using the NLS setting.

You can alter the NLS_LANGUAGE and NLS_TERRITORY for your session and use the TO_CHAR function to achieve the desired behavior as follows:

SQL> alter session set NLS_LANGUAGE=AMERICAN;

Session altered.

SQL> alter session set NLS_TERRITORY=AMERICA;

Session altered.

SQL>
SQL> SELECT TO_CHAR(1800,'L99G999D00') salary FROM DUAL;

SALARY
--------------------
$1,800.00

SQL>

You can see current NLS setting using following Views:

  1. NLS_SESSION_PARAMETERS
  2. NLS_DATABASE_PARAMETERS
  3. NLS_INSTANCE_PARAMETERS

SQL to querying a table with a dollar sign

try selecting exact identifier by pattern:

select oid::regclass from pg_class where relname ilike '%5ua5d%';

E.g:

so=# create table t."WeirdMix$" ();
CREATE TABLE
Time: 55.750 ms
so=# select oid::regclass from pg_class where relname ilike '%mix%';
oid
---------------
t."WeirdMix$"
(1 row)

Time: 90.814 ms

How to select elements by attribute's value when values contains dollar sign?

You quote the value:

jQuery ('[name="ctl00$ContentPH$ucFuncionEdit1$ckEsMenu"]');

When dealing with attribute selectors, it's best to always quote the value (although if the value is a single word containing only the letters A-Z [case insensitive] and the digits 0-9 [but not starting with a digit], you can get away without).



Related Topics



Leave a reply



Submit