| |

VerySource

 Forgot password?
 Register
Search
View: 1493|Reply: 4

How to sum, if the field type is character type?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Australia

Post time: 2020-11-26 23:30:01
| Show all posts |Read mode
SELECT SUM(cSng(mid(editorPay, 4))) AS editorPayTotal FROM table1

Among them is editorPay character type
For example: RMB33.45
      RMB136.55

Syntax error? Please give pointers, thank you!
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-11-27 07:30:01
| Show all posts
SELECT SUM(cSng(cast(right(editorPay,len(editorPay)-3) as numeric(9,2)))) AS editorPayTotal FROM table1
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Australia

 Author| Post time: 2020-11-27 22:15:01
| Show all posts
Thank you very much, it is finalized in one fell swoop^_^
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-28 15:15:02
| Show all posts
Use LEFT RIGHT MID LEN and other character processing functions to remove RMB, then use CLNG CDBL and other functions to transfer it to process it.
Reply

Use magic Report

0

Threads

23

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-11-28 15:30:01
| Show all posts
Use Mid(), left(), right(), cdbl() and other functions for processing.

Access does not support the cast() function, which is a function of SQL Server.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list