473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

case when gone wrong

I meant for the following query (run on a friday) to return "FRIDAY" in the first column and "1" in the second column. It returns FRIDAY alright, but in the second column returns 0. Can anyone tell my why and how to fix it?

SELECT a.dayofweek, (CASE WHEN a.dayofweek = 'FRIDAY' THEN 1 ELSE 0 END) daynum
FROM (SELECT TO_CHAR(sysdate,'DAY') as dayofweek
FROM dual
) a
Aug 8 '08 #1
2 1452
r035198x
13,262 8TB
The field might not be exactly 'FRIDAY' in the database. Perhaps there are extra spaces e.t.c. Try TRIMming the values before comparing.
Aug 11 '08 #2
debasisdas
8,127 Expert 4TB
As suggested in the previous post ry the following.

Expand|Select|Wrap|Line Numbers
  1. SELECT a.dayofweek, (CASE WHEN TRIM(a.dayofweek) = 'MONDAY' THEN 1 ELSE 0 END) daynum
  2. FROM (SELECT TO_CHAR(sysdate,'DAY') as dayofweek
  3. FROM dual
  4. ) a 
  5.  
  6.  
Aug 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse...
5
by: sriram | last post by:
I have the following: class BSA { ... ... ... ... public: enum VRGAttrId {
3
by: Matik | last post by:
Hello all, I belive, my problem is probably very easy to solve, but still, I cannot find solution: declare @i int declare @z int create table bubusilala (
17
by: Martin | last post by:
Below is some sample code to illustrate two warnings I get using a Hitachi compiler. When I use the GCC compiler I get a clean compile. I'd be grateful if someone could explain what the warnings...
2
by: Ole Hanson | last post by:
Hi Trying to access the users desktop items, I want to use the following method: string url = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); But - the...
3
by: AH | last post by:
Hi all, I noticed this strange behavior; I created a new control (example inherits from textbox) and add a new property, then I bind this new property to a field in my dataTable in a dataSet....
15
by: Benny Raymond | last post by:
I'm confused as to how fallthrough is limited in switch. For example the following works: string switch_test = "a"; switch (switch_test) { case "a": case "b": case "c": doSomething(a);
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.