Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need help with my stored procedure

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2008-07-25 : 09:00:54
I am not getting ICTU and I&E results could you tell me what I'm doing wrong?

Thanks


@Mod Varchar(10),
@FromDate DATETIME,
@ToDate DATETIME
)
AS

SET NOCOUNT ON

SELECT *
FROM SPSListings
WHERE CASE
When module = 'C12' then 'ICTU'
When module = 'I1' then 'I&E'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '0000' AND '0908' THEN '01'
WHEN RIGHT(Claim, 4) BETWEEN '0909' AND '1817' THEN '02'
WHEN RIGHT(Claim, 4) BETWEEN '1818' AND '2726' THEN '03'
WHEN RIGHT(Claim, 4) BETWEEN '2727' AND '3635' THEN '04'
WHEN RIGHT(Claim, 4) BETWEEN '3636' AND '4544' THEN '05'
WHEN RIGHT(Claim, 4) BETWEEN '4545' AND '5453' THEN '06'
WHEN RIGHT(Claim, 4) BETWEEN '5454' AND '6362' THEN '07'
WHEN RIGHT(Claim, 4) BETWEEN '6363' AND '7271' THEN '08'
WHEN RIGHT(Claim, 4) BETWEEN '7272' AND '8180' THEN '09'
WHEN RIGHT(Claim, 4) BETWEEN '8181' AND '9089' THEN '10'
WHEN RIGHT(Claim, 4) BETWEEN '9090' AND '9999' THEN '11'
END = @Mod
AND PmtDate BETWEEN @FromDate AND @ToDate
ORDER BY PmtDate

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-07-25 : 09:32:51
That's a bit tricky with the info given and, in particular, without seeing some data.

* What exactly do you mean by "not getting ICTU and I&E results"?
* What values are you using for your parameters?
* Are there any records in SPSListings with a value of 'C12' or 'I1' in the module column?

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-25 : 10:28:29
you need to specify what your expected logic is and also provide some sample data to illustrate it if you need quick and accurate soln.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2008-07-25 : 11:22:14
So sorry here's the table. Don't know how to line them all up but it's four columns:

SPSID Claim StatusCode Module
1 Abc3897 07 05
1 Abc5887 07 07
1 Abc0897 07 01
1 Abc7797 07 09
1 Abc5497 07 C12
1 Abc2297 07 I1

Here's the stored procedure:

@Mods CHAR(9),
@FromDate DATETIME,
@ToDate DATETIME
)
AS

SET NOCOUNT ON

SELECT *
FROM SPSListings
WHERE CASE
When module = 'C12' then 'ICTU'
When module = 'I1' then 'I&E'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '0000' AND '0908' THEN '01'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '0909' AND '1817' THEN '02'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '1818' AND '2726' THEN '03'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '2727' AND '3635' THEN '04'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '3636' AND '4544' THEN '05'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '4545' AND '5453' THEN '06'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '5454' AND '6362' THEN '07'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '6363' AND '7271' THEN '08'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '7272' AND '8180' THEN '09'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '8181' AND '9089' THEN '10'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '9090' AND '9999' THEN '11'

END = @Mods
AND PmtDate BETWEEN @FromDate AND @ToDate
ORDER BY PmtDate
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-25 : 11:30:12
quote:
Originally posted by JJ297

So sorry here's the table. Don't know how to line them all up but it's four columns:

SPSID Claim StatusCode Module
1 Abc3897 07 05
1 Abc5887 07 07
1 Abc0897 07 01
1 Abc7797 07 09
1 Abc5497 07 C12
1 Abc2297 07 I1

Here's the stored procedure:

@Mods CHAR(9),
@FromDate DATETIME,
@ToDate DATETIME
)
AS

SET NOCOUNT ON

SELECT *
FROM SPSListings
WHERE CASE
When module = 'C12' then 'ICTU'
When module = 'I1' then 'I&E'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '0000' AND '0908' THEN '01'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '0909' AND '1817' THEN '02'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '1818' AND '2726' THEN '03'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '2727' AND '3635' THEN '04'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '3636' AND '4544' THEN '05'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '4545' AND '5453' THEN '06'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '5454' AND '6362' THEN '07'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '6363' AND '7271' THEN '08'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '7272' AND '8180' THEN '09'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '8181' AND '9089' THEN '10'
WHEN RIGHT(ClaimSSN, 4) BETWEEN '9090' AND '9999' THEN '11'

END = @Mods
AND PmtDate BETWEEN @FromDate AND @ToDate
ORDER BY PmtDate



ok thanks. but whats that your epecting? plzz explain that too out of data you provided.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2008-07-25 : 13:51:30
The module's have been changed to different names. In the database I have listed C12 which is ICTU module and I1 which is called I&E.

All the other modules are determined by the last four digits of the claim number.

On the page I have a drop down box of modules
01 - 11, ICTU and I&E a top textbox and from textbox (to enter dates)

If you select module 01 and enter a from and to date you get that data.

If you select ICTU (module) and enter from and to date you get that info pertaining to ICTU data

I am using the Claim field to get the modules from 01 - 11

I am using the module field to get the data pertaining to ICTU and I&E

Is my case statement set up correctly?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-25 : 13:57:36
quote:
Originally posted by JJ297

The module's have been changed to different names. In the database I have listed C12 which is ICTU module and I1 which is called I&E.

All the other modules are determined by the last four digits of the claim number.

On the page I have a drop down box of modules
01 - 11, ICTU and I&E a top textbox and from textbox (to enter dates)

If you select module 01 and enter a from and to date you get that data.

If you select ICTU (module) and enter from and to date you get that info pertaining to ICTU data

I am using the Claim field to get the modules from 01 - 11

I am using the module field to get the data pertaining to ICTU and I&E

Is my case statement set up correctly?


yup case looks fine. why what is happening when you're passing I&E or ICTU?
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2008-07-25 : 14:56:04
I don't get any data returned which is odd.

Typed this query in SQL 2005:

Select SPSID, Claim, statuscode, Module
from Listings
where (module=I1)

I get this error

SQL Execution Error

Executed SQL Statement, SPSID, Claim, Statuscode, Module

from Listings whre (module=I1)
Error Source .NetSqlCient Data Provider
Error Message:Invalid Column name

I am not looking for a column named I1. Any Suggestions?
Go to Top of Page
   

- Advertisement -