HI, Is there any way to replicate the decode function in SQL Server 7.0? I have a problem where I have to write a query such that if the value in a column is '0' , I need to output it as 'No' and if it is '1', I need to output it as 'Yes'. An example of my problem is as follows:
select col_1+","+(value 'No' if col_2='0' and 'Yes' if col_2='1')+ ","+col_3+...........
I appreciate your help in advance. thanks, Sravan.
hi i have a view in oracle. in that i am using decode function. same query i want to write it in sqlserver. what it is the alternate to decode.
this is a cross tab query
SELECT code, SUM(DECODE(field1, 4, Present_Value, 0)) AS c1, SUM(DECODE(field1, 5, Present_Value, 0)) AS c2, SUM(DECODE(field1, 6, Present_Value, 0)) AS c3,SUM(DECODE(field1, 9, Present_Value, 0)) AS c4 FROM (SELECT field1,Code, Present_Value FROM table1) DERIVEDTBL GROUP BY code
FROM DOWNTIME_WEB WHERE DOWNTIME_WEB.TIMESTAMP>= (SELECT PRODN_SHIFT.START_DATIME FROM PRODN_SHIFT WHERE PRODN_SHIFT.START_DATIME <=sysdate AND PRODN_SHIFT.END_DATIME > sysdate) AND TRIM(DOWNTIME_WEB.STATUS_TEXT) = 'STOPPED' AND TRIM(DOWNTIME_WEB.WORK_CTR_NAME) = 'PACK2' ORDER BY DOWNTIME_WEB.EVENT_DUR
I have tried to put the DECODE etc into the GROUP BY statement but I get an error - " not a valid GROUP BY clause"
Secondly, is there a way of modifying value in field A based on the value in field B
Erroneous example follows - in an effort to explain what I want to do (from above):
DECODE(PRIM_REASN,'',(DECODE(EVENT_DUR,<200,"Low",>200,"High"),PRIM_REASN) ie:If PRIM_REASN is null I want EVENT_DUR to be tested to determine the new value for PRIM_REASN. Except that tthe above won't work and I don't know what the right function/argument should be..
This is my first foray into SQL server, I am trying to migrate some access queries to work with web services and hence Xcelsius.
I have a question about the "Decode" funktion. is it only avaiable in Oracle? The reason for my question is that I need to SELECT a colum in a table based on a int value. So if the uservalue is lower then that take that colum, lower then that take colum...etc.
Can I use decode? or/and is there better funktion (I'm using MS SQL 2005)
how can I write decode function in sql such that i have a feild in my table called "file type" based on its content i want to pass a value to sql datasource such that if file type = doc i want to pass "~/Images/ico_filetype_10.gif" an so on
I am a novice to SQL Server, so this is probably a really easy problemto fix. I'm translating an Oracle query and need to change the'decode' to something compatible. Everything I've read points me tousing 'case' but no matter how I write it I can't get it to work andget a syntax error. Suggestions?select SYST CTR, isnull(substring(CD_A, 1, 3), ' ') RESCODE, DES DESCRIPTION, decode (substring(CD_A, 1, 3), CODE,PRICE,0) UNIT_PRICE, count (distinct OR_NO) QTYW
I have a xml string which is consist of some images encoded in base64; I have to extract these images in a stored procedure and save them in some tables.
The problem is that I can't decode this base64s to images. Is there a way to do it? (I use SQL Server 2005 Enterprise)
how to execute this stored procedure to decode a varchar hexadecimal string? My SQL syntax stills have faded with the sands of time... I want to do a select * from the users table and decode the Password field (but not update) in the process.