I have created a single table in my primary DB called tblGlobalIDMapping that will assign a GUID to all entries and store the other 3 primary ID's across the App to provide for a single ID repository.
The new Table is in the following structure -->
AppGlobalID uniqueidentifier NoNulls
PersonID int NoNul...
Using a case-then block, I need to choose how to order my SQL 2008 query, by [status] ASC, [date] DESC or just [date] DESC.
I know only how to use one column:
SELECT *
FROM table
ORDER BY
CASE WHEN @flag = 0
THEN R.[date] END DESC,
CASE WHEN @flag = 1
THEN R.[status] END ASC
How to use both columns in second CASE?
...
Is there a way to rewrite a Transact SQL statement that uses a CASE WHEN structure to do the same without using the CASE WHEN?
I'm using a product that has a built-in query designer and its own pseudo-SQL. It has limitations on what I can use with SQL Server and Oracle. So I have this column that, when the underlying database is Oracle,...
I have searched this site extensively but cannot find a solution.
Here is the example of my query:
SELECT
ActivityID,
Hours = (CASE
WHEN ActivityTypeID <> 2 THEN
FieldName = (Some Aggregate Sub Query),
FieldName2 = (Some other aggregate sub query)
WHEN A...
I have to sort out my data by some column, such that some specific value appears first. So for a query like this ...
SELECT rtrim(taskid) into v_taskid FROM tasks
where
/* some where clausers */
and rownum = 1
... I have based it on case when, but what bothers me is three nested selects I have now:
SELECT rtrim(taskid) ...
I am trying to create a pivot table type view in postgresql and am nearly there! Here is the basic query:
select
acc2tax_node.acc, tax_node.name, tax_node.rank
from
tax_node, acc2tax_node
where
tax_node.taxid=acc2tax_node.taxid and acc2tax_node.acc='AJ012531';
And the data:
acc | name | rank
--...
Hi there.
Im creating customizable product attributes in a web store - each attribute can have different type of data, each data type is stored in a separate column using corresponding mysql datatype.
I Have a query like:
SELECT
products.id AS id,
products.sku AS sku,
products.name AS name,
products.url_key AS url_key,
attributes.name...
Thank you to everyone who tries to help!
I have 2 case select statements and I get the error on this statement:
Center,
Case Center
When 'Concord Call Center' Then 'CCC'
When 'Livermore Call Center' Then 'LCC'
When 'Morgan Hill Call Center' Then 'MHCC'
When 'Natomas Call Center' Then 'NCC'
When 'Virtual Call Center' Then 'VCC'
Else Cen...
Hello, my query returns a column that can hold types of real estate. Values can be condo or duplex or house and so on. Instead of displaying condo, I just want a C in the column. My plan was to use a huge case/when structure to cover all the cases, is there an easier way? Just displaying the first letter in upper case wont work by the wa...
Hello, I have a huge query which uses case/when often. Now I have this SQL here, which does not work.
(select case when xyz.something = 1
then
'SOMETEXT'
else
(select case when xyz.somethingelse = 1)
then
'SOMEOTHERTEXT'
end)
(select case when xyz.somethingelseagain = 2)
then
'...
I have a NVARCHAR(max) column in a table and a stored procedure that would update this column as well as any other column in the table using CASE switching:
CREATE PROCEDURE updateTable
@columnName sysname,
@value nvarchar(max)
AS
UPDATE [dbo].[TestTable]
SET
BigNvarcharValue = CASE @columnName WHEN 'BigNvarcharValue...
Hello Everyone!,
I want to refresh GridView based upon whether a particular <asp:CheckBox> has been selected or not.
I am using <asp:SqlDataSource with a SelectCommand and my query goes like this..
SelectCommand="SELECT * from [Table1] where [COL1] in (case when @checkbox=1 then 'FOO' else 'BAR')...
and the <SelectParameters> have b...