parsing values in SQL w/ delimiter

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
say my return value on a query is "Amount: $100.00" for "SALE_AMT" column.

But I only want the "100.00"
I KNOW there has to be an easy function for this in the query, but for the life of me I can not figure it out.
 
Last edited:

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
SUBSTRING(ACTIVE.NOTE, CHARINDEX('$', ACTIVE.NOTE) + 1, LEN(ACTIVE.NOTE)) AS Test


what a pain the ass. I can't believe they don't have something like RPARSE(ACTIVE.NOTE.'my choice of characeters>) built in.
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Substring(sales_amt, 9)

I thought of that, but sadly I left out a bit of info.

"Amount?: $100.00" is a fixed width value.
So when its $100.00 there are 10 spaces between the : and the $. If it's $1000.00 there are 9 spaces...
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
Similar to your other thread if it's always "AMOUNT: " then use replace. If you must use 3 replaces, one for "AMOUNT:" one for "$" and one for all spaces.
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Similar to your other thread if it's always "AMOUNT: " then use replace. If you must use 3 replaces, one for "AMOUNT:" one for "$" and one for all spaces.

Oh I like that solution too! sneaky.:ninja:

As I get more and more into SQL and more elaborate reports/queries, that is one thing I like about it; there's always a dozen ways to do 1 thing... each better than the next.
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
yeap. I'm familiar with "RIGHT", and have used it on a few occasions.
Thanks.
 

beginner99

Diamond Member
Jun 2, 2009
5,223
1,598
136
SUBSTRING(ACTIVE.NOTE, CHARINDEX('$', ACTIVE.NOTE) + 1, LEN(ACTIVE.NOTE)) AS Test


what a pain the ass. I can't believe they don't have something like RPARSE(ACTIVE.NOTE.'my choice of characeters>) built in.

Or one could say its retarded to store "Amount?: $100.00". Not your fault but the guy that came up with this idea sure didn't understand what a relational database is.
It's like driving your car into a river and then wonder why it doesn't float.
Excel freaks are a PITA.
 

ForumMaster

Diamond Member
Feb 24, 2005
7,797
1
0
Similar to your other thread if it's always "AMOUNT: " then use replace. If you must use 3 replaces, one for "AMOUNT:" one for "$" and one for all spaces.

A better way is this:

substring is a functions that requires as input:
that column
from where to begin
where to end

if you use 3 replaces each time on the column, that's 3 additional function calls.
it adds overhead.

the preferred method is this: using instr (a function that returns the position of a string in another string). it requires as input a column and the string to find.


an example:

substr(active.note,instr(active.note,'$')+1)

that's it. you don't have to provide the third parameter for substr if you want the rest of the string (length of column).
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |