I have the following code :
select {?TroubleType}
case "All Types":
{tbl_tickets.CustomerAcctNumber} <> '0' and
{tbl_tickets.OpenDate} >= {?BeginDate} and
{tbl_tickets.OpenDate} <= {?EndDate} and
{tbl_tickets.CustomerAcctNumber} <> '184114' and
{tbl_tickets.TroubleType} <> ""
case {?TroubleType}:
{tbl_tickets.TroubleID}<> 0 and
{tbl_tickets.OpenDate}>= {?BeginDate} and
{tbl_tickets.OpenDate}<= {?EndDate} and
{tbl_tickets.CustomerAcctNumber}<> '184114' and
{tbl_tickets.TroubleType}= {?TroubleType}
and I need to duplicate it for 3 other parameter fields. Is there a way to nest the case statements - I continually get an error everytime I try add just one other case statement to a new parameter...Not clear. U want to put on case within another?|||Yes -
I need to do this same type of functionality for a total of 4 parameters - and have it interchangeably choose the option selected or all for each individual paramter:
example: Give me all the cities
and just troubletype of -email
with all the status
Or Just this city, with just this trouble with just open status...|||Still I'm not clear. But if you want to nest ur case statements, here is an example
//starts here
select {?state}
case "MN" :
(
select {?city}
case "City A" :
"here is some code for city A"
case "City B" :
"here is some code for city B"
)
case "CA" :
"Here is some code for CA"
case "FL" :
"Here is some code for FL"
Showing posts with label types. Show all posts
Showing posts with label types. Show all posts
Monday, March 12, 2012
Nested Cases - is it possible?
Labels:
andtbl_tickets,
cases,
code,
customeracctnumber,
database,
following,
ltgt,
microsoft,
mysql,
nested,
opendate,
oracle,
select,
server,
sql,
tbl_tickets,
troubletypecase,
types
Friday, March 9, 2012
negative sign (unary operator) not displayed for numeric data types
I have a table with a field that has a numeric data type (15,2) and length of 9. The problem is that it won't display the actual negative sign for any values less than 0 when running a query. Any ideas? I've used Query Analyzer as well as Access.
Thanks.Huh?
DECLARE @.x decimal(15,4)
set @.x = -12345.1234
SELECT @.x|||Maybe this will help.
For instance, one customer in the table has values like this:
4380.00
4380.00
8760.00
4380.00
4380.00
23360.00
23360.00
but actually it should be:
4380.00
-4380.00
8760.00
-4380.00
-4380.00
23360.00
-23360.00
which nets to a total of 0. And if I change the query to a group query and perform a sum on this revenue field I will get 0 but if I do a normal select I'll get all positives. Sql server knows that some of the revenue is negative it just doesn't display the - sign infront of it.
Btw:
DECLARE @.x decimal(15,4)
set @.x = -12345.1234
SELECT @.x
works correctly.|||How are you viewing the data? I betcha it's a front end issue?
Or are yu seeing this in QA.
Read the huint sticky at the top of the board and post what it asks for|||"select [Value] from [YourTable] where [Value] < 0" returns what?|||I've gotten the same results using Access as the front end linking the sql server table and using Query Analzyer. I will take a look at that sticky.
If I run the same query with the < 0 criteria I will get values returned that look positive. I even copied and pasted the values into Excel and they still show up as positive values.
If I change the data type to float it works fine, but for some reason numeric data type won't display negative values.|||are you sure you aren't running this:
select abs(mycol) from mytable where mycol < 0
in any case I can't repro it:
declare @.t table (col decimal(15,2))
insert into @.t
select -12.11 union all select 234.33 union all select -44.444
select * from @.t
col
------------
-12.11
234.33
-44.44|||Sorry etaktaf, but unless you can provide us with some code for replicating this problem (create table, populate table, select results...), then I don't think we can help you any further.|||In other words post some examplkes as the hint link states
Thanks.Huh?
DECLARE @.x decimal(15,4)
set @.x = -12345.1234
SELECT @.x|||Maybe this will help.
For instance, one customer in the table has values like this:
4380.00
4380.00
8760.00
4380.00
4380.00
23360.00
23360.00
but actually it should be:
4380.00
-4380.00
8760.00
-4380.00
-4380.00
23360.00
-23360.00
which nets to a total of 0. And if I change the query to a group query and perform a sum on this revenue field I will get 0 but if I do a normal select I'll get all positives. Sql server knows that some of the revenue is negative it just doesn't display the - sign infront of it.
Btw:
DECLARE @.x decimal(15,4)
set @.x = -12345.1234
SELECT @.x
works correctly.|||How are you viewing the data? I betcha it's a front end issue?
Or are yu seeing this in QA.
Read the huint sticky at the top of the board and post what it asks for|||"select [Value] from [YourTable] where [Value] < 0" returns what?|||I've gotten the same results using Access as the front end linking the sql server table and using Query Analzyer. I will take a look at that sticky.
If I run the same query with the < 0 criteria I will get values returned that look positive. I even copied and pasted the values into Excel and they still show up as positive values.
If I change the data type to float it works fine, but for some reason numeric data type won't display negative values.|||are you sure you aren't running this:
select abs(mycol) from mytable where mycol < 0
in any case I can't repro it:
declare @.t table (col decimal(15,2))
insert into @.t
select -12.11 union all select 234.33 union all select -44.444
select * from @.t
col
------------
-12.11
234.33
-44.44|||Sorry etaktaf, but unless you can provide us with some code for replicating this problem (create table, populate table, select results...), then I don't think we can help you any further.|||In other words post some examplkes as the hint link states
Saturday, February 25, 2012
Need Unicode question answered ASAP
I have a question regarding data types on Windows 2000 SVC Pk 4 & SQL Server
2000 Svc Pack 3a:
If I convert a char(20) Column to NChar, should I be using
Nchar (20) or Nchar(40)?
Thanks much.NCHAR(20). For Unicode data types nchar & nvarchar, the length refers to
the number of (2-byte) Unicode characters you can store, not the number
of bytes.
HTH,
Bart
--
Bart Duncan
Microsoft SQL Server Support
Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Thread-Topic: Need Unicode question answered ASAP
thread-index: AcP66G4a/faD4EnrQkeJGb/105yR6Q==
X-Tomcat-NG: microsoft.public.sqlserver.server
From: "examnotes" <anonymous@.discussions.microsoft.com>
Subject: Need Unicode question answered ASAP
Date: Tue, 24 Feb 2004 07:11:08 -0800
Lines: 8
Message-ID: <D4B67A56-C3B4-4FC9-B1C0-AE6E88A01ADD@.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.sqlserver.server
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:330913
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.sqlserver.server
I have a question regarding data types on Windows 2000 SVC Pk 4 & SQL
Server 2000 Svc Pack 3a:
If I convert a char(20) Column to NChar, should I be using
Nchar (20) or Nchar(40)?
Thanks much.
2000 Svc Pack 3a:
If I convert a char(20) Column to NChar, should I be using
Nchar (20) or Nchar(40)?
Thanks much.NCHAR(20). For Unicode data types nchar & nvarchar, the length refers to
the number of (2-byte) Unicode characters you can store, not the number
of bytes.
HTH,
Bart
--
Bart Duncan
Microsoft SQL Server Support
Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Thread-Topic: Need Unicode question answered ASAP
thread-index: AcP66G4a/faD4EnrQkeJGb/105yR6Q==
X-Tomcat-NG: microsoft.public.sqlserver.server
From: "examnotes" <anonymous@.discussions.microsoft.com>
Subject: Need Unicode question answered ASAP
Date: Tue, 24 Feb 2004 07:11:08 -0800
Lines: 8
Message-ID: <D4B67A56-C3B4-4FC9-B1C0-AE6E88A01ADD@.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.sqlserver.server
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:330913
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.sqlserver.server
I have a question regarding data types on Windows 2000 SVC Pk 4 & SQL
Server 2000 Svc Pack 3a:
If I convert a char(20) Column to NChar, should I be using
Nchar (20) or Nchar(40)?
Thanks much.
Subscribe to:
Posts (Atom)