| Author |
Topic |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-12-02 : 08:12:15
|
| I am trying to hardcode 'N/A' when a null value appears in the 'dormant_date' column. When I run the below query, null is still appearing in the 'dormant_date' column.select symbol,'dormant_date' = casewhen CONVERT(varchar,coalesce(c.dormant_date , '')) = '' then 'N/A' elsec.dormant_dateendfrom billing_invoices biCurrently, my data looks something like this when I run the above query:L8 NULLL8 NULLL8 NULLL99 2007-03-08 00:00:00.000Any thoughts? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-02 : 08:17:01
|
| 1 If you use front end application, show 'N/A' there2 Otherwiseselect symbol,coalesce(convert(char(10),c.dormant_date,101), 'N/A') as dormant_datefrom billing_invoices biMadhivananFailing to plan is Planning to fail |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-12-02 : 08:31:12
|
| Perfect, thanks Madhivanan! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-02 : 08:36:32
|
quote: Originally posted by qman Perfect, thanks Madhivanan!
Note that now the dates are actually characters that you may not treat it as a dateMadhivananFailing to plan is Planning to fail |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-12-02 : 09:23:40
|
| Thanks, the results are just for analysis purposes. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-02 : 09:26:56
|
quote: Originally posted by qman Thanks, the results are just for analysis purposes.
Then, no problemMadhivananFailing to plan is Planning to fail |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-12-02 : 09:30:03
|
| Now I am getting a "Arithmetic overflow error converting expression to data type int." select c.symbol, sum(bi.volume) as volfrom invoices biinner join company c on bi.company_id = c.company_idgroup by c.symbol |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-12-02 : 09:32:47
|
| I got it to work by casting the sum() to sum(cast(bi.volume as bigint)) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-02 : 09:35:15
|
quote: Originally posted by qman Now I am getting a "Arithmetic overflow error converting expression to data type int." select c.symbol, sum(bi.volume) as volfrom invoices biinner join company c on bi.company_id = c.company_idgroup by c.symbol
You are supposed to post herehttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=136653MadhivananFailing to plan is Planning to fail |
 |
|
|
|