Showing posts with label build. Show all posts
Showing posts with label build. Show all posts

Monday, March 26, 2012

MOD Equivalent in SQl Server?

I'm trying to build a query that I'd like only run on records with an odd
number in a specific field.
Using the "MOD" function, I'd simply throw a criteria in that says where
"Field Mod 2 <> 0"
Is there a mod function in SQL Server 2K? I can't find it... If not,
what's my alternative?
Thanks in advance...
gThe "%" character is the modulo function, so try
Field % 2 <> 0
"Greg Toronto" wrote:

> I'm trying to build a query that I'd like only run on records with an odd
> number in a specific field.
> Using the "MOD" function, I'd simply throw a criteria in that says where
> "Field Mod 2 <> 0"
> Is there a mod function in SQL Server 2K? I can't find it... If not,
> what's my alternative?
> Thanks in advance...
> g|||>> Using the "MOD" function, I'd simply throw a criteria in that says where
"Field Mod 2 <> 0" <<
They stole the infixed % from C; the ANSI/ISO syntax is MOD(). But be
careful and try your MOD to see how you expect negative numbers to
work. This was a big problem in Standardizing Pascal years ago.

Monday, March 19, 2012

Missing Value Grouping

Newbie SQL Question.

I need to build a results grid that reports totals or zero for an attribute

SELECT ClaimType, VendorNumber,
COUNT (ClaimNumber) AS ClaimCount
FROM ClaimHeader
GROUP BY VendorNumber, ClaimType
ORDER BY VendorNumber ASC;

THe underlying data has two claim types (UB, and HCFA). Some vendor numbers have only UB claims or only HCFA claims. I want my totals to show a zero for those vendor numbers. Example

VendorNumber ClaimType ClaimCount
234 UB 21
234 HCFA 12
235 UB 0
235 HCFA 15

My current group by doesn't give me the 3rd row in my example. How do I change my query to add those rows that have no claims as a zero. Put another way, every vendorNumber has to report a HCFA total and a UB total, even if they're zero.

Thanks.This is flat-out "brute force" to get the job done using only what you've given us... There is almost certainly a better way.SELECT v.VendorNumber, c.ClaimType, (SELECT Coalesce(Count(*), 0)
FROM ClaimHeader AS ch
WHERE ch.VendorNumber = v.VendorNumber
AND ch.ClaimType = c.ClaimType) AS ClaimCount
FROM (SELECT DISTINCT VendorNumber
FROM ClaimHeader) AS v
CROSS JOIN (SELECT DISTINCT ClaimType
FROM ClaimHeader) AS c-PatP|||Is something else I could provide to help with my question? This might b closer but i'm still missing the zeros for providers with not HCFA or UB claims.

SELECT t.PeriodID, p.ProviderName, p.AltProviderID_1,
t.FormTypeID,
ClaimCount = CASE WHEN SUM(ClaimCount) IS NULL THEN 0 ELSE SUM(ClaimCount) END

FROM dvTATClaim t
INNER JOIN dimProvider p
ON t.ProviderID = p.ProviderID|||Sure...provide the DDL of the table

CREATE TABLE myTable...

Some Sample Data

INSERT INTO myTable(
SELECT 'data' UNION ALL
SELECT 'data' UNION ALL
ect

And what the results should look like...

You could probably use a stop watch to time how long it takes after you post that for your answer...|||Are there other tables that have:
1. Every possible VendorNumber
2. Every possible ClaimType

Also, did the previous query I provided give you the results that you want?

-PatP

Friday, March 9, 2012

Missing SQL Server Project template

I have VS2005 Beta 2 (build 8.0.50215.44) and the June CTP of SQL Server 2005 Developer Edition installed.

Within VS2005, when I go to File -> New Project, I don't have the "Database" project type under either VB or C#. Which also means that the "SQL Server Project" template is not being offered.

Is there a manual way of adding the template, or some other workaround/solution?

Which SKU of Visual Studio are you using? Visual Studio Express does not have SQL Server project support.

Thanks,
-Vineet.

|||It's the full version of Visual Studio 2005, Beta 2, that was released in mid April.|||Actually database projects are not availble in VS Express and VS Standard editions. It sounds like that is what you have. Can you confirm?|||Which editions of VS.Net 2005 do have the "SQL Server" project templates? Or can they be downloaded from somewhere? (I have not been able to find such a place...)
Many thanks.
|||Nevermind. I have VS.Net 2005 Beta2 and didn't notice that if I expanded the Visual C# under the project types tree, there was a database node which contained the "SQL Server" project template.
Take care.