DECLARE @TestVal int
SET @TestVal = 5
SELECT
CASE
WHEN @TestVal <=3 THEN 'Top 3'
ELSE 'Other'
END
I saw this sample code online but I couldn't find an example where there was no expression and it had more than one WHEN, so I am wondering if this type of thing is OK:
DECLARE @TestVal int
SET @TestVal = 5
SEL...
Note: this is not a duplicate of Jeff's question.
That question asked "Is an equivalent?" I know there isn't, and I want to know why!
The reason I ask is that I've only just become clear on how important it is, and the conclusion seems very strange to me.
The Exception Handling block of Microsoft's Enterprise Library advises us to use...
I'm trying to select some integer values in MySQL. Several of the values are zero, which I want to grab as an empty string, and grab the integer values when available.
So I have something like this:
SELECT CASE field WHEN 0 THEN '' ELSE field, [repeat for other fields]
Is there any way to shorten this in the SQL query? Does MySQL sup...
Hi,
When should I take it into consideration whether my method is thread-safe or not?
thanks,
kalem keki
...
Hi,
My requirement is to display a Column in select query when a condition satisfies and not to display the column when condition is not matched.
For eg : In this simple table below
Table : XYZ
Name ID Fairness
harish 3 White
ravi 5 brown
arun 2 black
rahul 5 white
Query:
select name,case id when 5 then " I Like to learn more...
I'm tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here's the entire function, based on XSLT Cookbook:
<xsl:template name="tokenize">
<xsl:param name="string" select="''" />
<xsl:param name="delimiters" select="';#'" />
<xsl:param name="tokensplitter" select="','" />
...
does anybody know how to do this syntax below in mysql?
without Stored Procedure
and in single query only
SELECT CASE
WHEN COUNT(v.value) = 0 THEN (
INSERT INTO tbl_v (fid, uid, VALUE)
SELECT fid, 1 AS uid, 'xxxxxx' AS VALUE FROM tbl_f
WHERE category = 'categoryname' AND NAME = 'somevalue'
)WHEN v.value <> 'test' THEN (
'u...
Hi Guys:
I am in an urgent need of having the print layout thing based on the one fied condition. Let us say I have a shipment label layout with 50 fields in it and which is working. But before I print that, I have a condition saying that if Number of Packages is 0 do not print at all. Just print an error message saying that no packag...
Here is the query in Oracle I was trying to remove the redundant math operation from:
SELECT name,
CASE
when nvl(num1,0) + nvl(num2,0) - nvl(num3,0) > 0
THEN nvl(num1,0) + nvl(num2,0) - nvl(num3,0)
ELSE 0
END
as result,
.... from ....
How do I not repeat the summation above?
The 'result...
I have an accounts table and a records table where accounts have multiple records. I would like to break down the account totals by "count of records" range. i.e. show the breakdown of
Count of Records | Count
0-25 | 100
25 - 50 | 122
50 - 100 | 300
etc.
I am using the following query, but I can't get it to group by "grp" which is ...
Hi, I am stuck in a Clojure loop and need help to get out.
I first want to define a vector
(def lawl [1 2 3 4 5])
I do
(get lawl 0)
And get "1" in return. Now, I want a loop that get each number in the vector, so I do:
(loop [i 0]
(if (< i (count lawl))
(get lawl i)
(recur (inc i))))
In my mind this is supposed...
ok i think i am pushing my self to far here, im createing a project in my own mvc even i dont know what mvc its self,
<?php
class init
{
function __construct()
{
$this->enviroment();
$this->start();
}
function enviroment()
{
/* Required Classes */
...
Hi,
I am new to F# and fiddling just around with it.
What get's me is:
let rec fact n =
match n with
| dummy when n < 2 -> 1
| _ -> n * fact (n - 1)
let x = 6
printfn "%d! = %d" x (fact x)
Why does F# needs this dummy placeholder between pipe and when?
Dummy is even the whole time undefined and the compiler seems in some w...