Discussione:
SQL : String to numeric
(troppo vecchio per rispondere)
Giovanni
2005-03-10 08:08:16 UTC
Permalink
esiste una funzione in sql per convertire un valore stringa in numerico ?

Ho un file dove devo sommare un campo dichiarato stringa ma che contiene
valori numerici e vorrei fare una cosa del genere:

SELECT CLIENTE, SUM(.....(ORDINATO))
FROM miofile
group by cliente
ordrer by cliente

il campo ORDINATO è una stringa di 6 con valori tra "000000" e "999999"

Grazie
Giovanni
lely70
2005-03-10 08:40:56 UTC
Permalink
Post by Giovanni
Ho un file dove devo sommare un campo dichiarato stringa ma che contiene
Dal manuale:

┌────────────────────────────────────────────────────────────────────────┐
│ │
│ │
│ >──DIGITS──(──expression──)──────────────────────────────────────────> │
│ │
└────────────────────────────────────────────────────────────────────────┘
The DIGITS function returns a character-string representation of the
absolute value of a number.

The argument must be an integer or decimal value.

If the argument can be null, the result can be null; if the argument is
null, the result is the null value.

The result of the function is a fixed-length character string representing
the absolute value of the argument without regard to its scale. The
result does not include a sign or a decimal point. Instead, it consists
exclusively of digits, including, if necessary, leading zeros to fill out
the
string. The length of the string is:

5, if the argument is a small zero scale integer

10, if the argument is a large zero scale integer

p, if the argument is a decimal or nonzero scale integer with a
precision of p


The CCSID of the character string is the default SBCS CCSID at the current
server.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
Giovanni
2005-03-10 08:51:06 UTC
Permalink
Nel mio manuale questa istruzione serve per convertire i valori numerici in
stringa e non viceversa.

Grazie cmq.
Giovanni
Post by Giovanni
Ho un file dove devo sommare un campo dichiarato stringa ma che contiene
‚€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ƒ
 
 
 >€€DIGITS€€(€€expression€€)€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€> 
 
„€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€…
The DIGITS function returns a character-string representation of the
absolute value of a number.
The argument must be an integer or decimal value.
If the argument can be null, the result can be null; if the argument is
null, the result is the null value.
The result of the function is a fixed-length character string representing
the absolute value of the argument without regard to its scale. The
result does not include a sign or a decimal point. Instead, it consists
exclusively of digits, including, if necessary, leading zeros to fill out
the
5, if the argument is a small zero scale integer
10, if the argument is a large zero scale integer
p, if the argument is a decimal or nonzero scale integer with a
precision of p
The CCSID of the character string is the default SBCS CCSID at the current
server.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
lely70
2005-03-10 09:00:54 UTC
Permalink
Post by Giovanni
Nel mio manuale questa istruzione serve per convertire i valori numerici in
stringa e non viceversa.
Occavolo nella fretta ho sbagliato nel confondermi ;-p

Hai rovato con CAST?
Se ti serve ti mando la pagina del manuale che e' un po' lunga.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
lely70
2005-03-10 09:01:14 UTC
Permalink
Post by Giovanni
Nel mio manuale questa istruzione serve per convertire i valori numerici in
stringa e non viceversa.
Occavolo nella fretta ho sbagliato nel confondermi ;-p

Hai provato con CAST?
Se ti serve ti mando la pagina del manuale che e' un po' lunga.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
Giovanni
2005-03-10 09:44:39 UTC
Permalink
CAST(ORDINI as numeric(5, 2))

OK funziona.
Grazie
Giovanni
Post by lely70
Post by Giovanni
Nel mio manuale questa istruzione serve per convertire i valori numerici in
stringa e non viceversa.
Occavolo nella fretta ho sbagliato nel confondermi ;-p
Hai provato con CAST?
Se ti serve ti mando la pagina del manuale che e' un po' lunga.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
lely70
2005-03-10 10:07:03 UTC
Permalink
Post by Giovanni
OK funziona.
Ottimo, e mi dispiace per il fraintendimento, questa mattina non carburo.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
Gianfranco Levati
2005-03-15 15:38:06 UTC
Permalink
Post by lely70
Post by Giovanni
OK funziona.
Ottimo, e mi dispiace per il fraintendimento, questa mattina non carburo.
boh. a me basta fare un DECIMAL(stringa,interi,decimali) e il cast me lo
fa implicito.
possibile?
--
Gianfranco Levati


questo articolo e` stato inviato via web dal servizio gratuito
http://www.newsland.it/news segnala gli abusi ad ***@newsland.it
lely70
2005-03-15 15:40:32 UTC
Permalink
Post by Gianfranco Levati
boh. a me basta fare un DECIMAL(stringa,interi,decimali) e il cast me lo
fa implicito.
possibile?
Si, in pratica fanno lo stesso lavoro, ma la CAST e' piu' generica.

Gia' che c'ero pensavo fosse meglio segnalare qualcosa di piu' flessibile.
--
Ciao, Valerio
Sono intorno a me ma non parlano con me
Sono come me ma si sentono meglio
(Frankie Hi-Nrg Mc)
Loading...