Problem With SmallDateTime Attribute Selecting In Cases

Aug 29, 2007

Table "GprcAdj"

Code INT
StartDate SMALLDATETIME
EndDate SMALLDATETIME
Rate FLOAT
Factor FLOAT
________________________________________________

Querey

Select (Case




when @ITEM = 1 then GprcAdj.StartDate

when @ITEM = 2 then GprcAdj.Rate

when @ITEM = 3 then GprcAdj.Factor

end)

from GprcAdj

________________________________________________
When i use above querey and want to select any one of Attribute then it works right for @ITEM = 1 or 2 but for Item 3 it not shows the 'Factor' and show DateValues on option 3 which is wrong.
Also when i Change selection and select Code instead of Startdate then it works for all three Options.
so i guess that Startdate create a problem, but i dont know why it creating problem and how to resolve it
Plz give me some sugessions and solutions to resolve it.

View 3 Replies


ADVERTISEMENT

Selecting N-th Attribute

Jul 20, 2005

Hi!I have a following problem: I need to select some attributes fromtable, i.e.first, third, fifth...Can anyone give me the hint how to do it. Is there some method to saysomthing like this:SELECT $1, $3, $5 which will refer to the 1st, 3rd and 5th attribute?Thanks!Mario.

View 5 Replies View Related

Selecting XML Attribute

Mar 10, 2008

I am trying to retrive some values from and XML data colum , along with that i need other normal column data also . how can i do that ?

here is my problem


I have a table with 2 colum .

Column Data Type
ID Int
Data XML


The XML data looks like following

<A>
<B a = 'sun' b = 'Red' >
</B>
<A>


I want to get each id and the 'b' attribute of the B node of the xml data for each row ?

Please help me if there is any simple way to do this .

View 5 Replies View Related

SQL Server 2014 :: How To Check Existing Attribute In Insert Attribute In XML Field

Aug 10, 2015

I want to insert attibute att1 in field F1 . Value for this attribute is content of another field in this table (F2).

My query :
update MyTable
set F1.modify
('insert attribute att1 {sql:column("F2")} into (/ROOT/Node1)[1]')
Where F1 Is not null

But I get this error :
XML well-formedness check: Duplicate attribute 'att1'. Rewrite your XQuery so it returns well-formed XML.

How do I check the douplicate attribute ?

View 0 Replies View Related

Measure Group Attribute Key Column Does Not Match Source Attribute

May 16, 2008



HI,


I had to change the key columns of a dimension attribute to fix an error. I did this in BIDS. The change was from a single key column to a composite key column. Now I am getting these error when I process the cube:

Measure group attribute key column x does not match source attribute ..

I looked at the cube XMLA definition under mesaure groups and it still shows a single key column with inherited binding. However, the BIDS does not give me an option correct this in any way. I have had to do this once before and the only option seems to be removing the dimension from the cube and add it back in. But that is very error prone since I lose any specific settings at the cube dimension level not to mention aggregations no longer include the dimension, etc.

Not seeing an alternative, I went through each measure group (I have 7) and changed the key columns manually in the XMLA and saved the cube. This worked, but I don't understand why BIDS automatically doesn't do it.

Is this a flaw in the BIDS or I should be missing something.

thanks
MJ

View 3 Replies View Related

The Conversion Of Char Data Type To Smalldatetime Data Type Resulted In An Out-of-range Smalldatetime Value

Mar 30, 2007

I am using Visual Studio 2005 and SQL Express 2005. The database was converted from MS Access 2003 to SQL Express by using the upsize wizard.



I would like to store the current date & time in a column in a table. This column is a smalldatetime column called 'lastlogin'.

The code I'm using is:



Dim sqlcommand As New SqlCommand _

("UPDATE tableXYZ SET Loggedin = 'True', LastLogin = GetDate() WHERE employeeID = '" & intEmployeeID.ToString & "'", conn)



Try

conn.Open()

sqlcommand.ExecuteNonQuery()

conn.Close()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try



This code works fine on my local machine and local SQL server. However at the client side this code results in the error as mentioned in the subject of this thread. I first used 'datetime.now' instead of 'getdate()', but that caused the same error. Then I changed the code to 'getdate()', but the error still remains.



The server at the client is running Windows Server 2000 UK . My local machiine is running WIndows XP Dutch.

Maybe the conversion from Dutch to UK has something to do with it. But this should be solved by using the 'Getdate()' function..... ?













View 1 Replies View Related

SQL Server Cases

Oct 11, 2005

Hi all,

I'm looking for some online resources here. Specifically, I'm interested in finding some case/project examples to learn more. I'm looking for any and all kinds in all areas...ADO, Security, Maintenance, etc. I've worn out google, but the most I seem to find is articles. I'm looking for actual Cases, like one you'd find in a text.

I have a text book from a couple of courses I took in school. Unfortunately it doesn't delve much into said areas. Any resources you could point me I will greatly appreciate it. I'd even be interested in some actual books if there's any that any of you have experience with that you think would help me out. Thanks for reading.

View 2 Replies View Related

ClusterDistance() Of Zero For All Cases

Jan 10, 2007

I recently added a nested table to a model that I had been using for a while. I noticed that after I added the nested table that the ClusterDistance() function returned 0 for every case. I went ahead and changed some of the keys for the nested table records so that the values would show up as missing and now the cases with a missing value have a non-zero ClusterDistance() value. Can anyone help me understand why this may be happening?

Thanks.

View 1 Replies View Related

Inserting With Cases

May 13, 2008

I have the following sproc that gets all the items from a queue with a few filters. I however need to return records where jobstepId is 1 and job jobqueuestatusid to be 4 if any jobqueuestatusid was 4 for that jobscheduleid, 2 if any is 2, and lastly 1. I tried inserting a
case when exists(select * from flexportjobqueueview where jobscheduleID = [jobscheduleID] and jobqueuestatusid = '4'
then 4,
else ..... then 3,
else ....... then 1,
end

that did not seem to work. It inserted 4 or 3's for all and not just the particular scheduleid. Any help on this will be great thanks
Ludwig

CREATE TABLE #QTEMP(
[JobQueueID][int],
[JobScheduleID][int],
[JobID][int],
[JobName][varchar](50),
[JobDesc][varchar](50),
[JobStepID][int],
[JobStepName][varchar](50),
[JobStepDesc][varchar](50),
[JobStepExecutable][varchar](100),
[JobQueueStatus_ID][int],
[JobQueueStatusDesc][varchar](100),
[NextRunDateTime][datetime],
[LastRunDateTime][datetime],
[ProcessID][int]
)ON[PRIMARY]
Declare @sql nvarchar(4000)
Set @sql='INSERT INTO #QTEMP
SELECT [JobQueueID],
[JobScheduleID],
[JobID],
[JobName],
[JobDesc],
[JobStepID],
[JobStepName],
[JobStepDesc],
[JobStepExecutable],
[JobQueueStatus_ID],
[JobQueueStatusDesc],
[NextRunDateTime],
[LastRunDateTime],
[ProcessID]
FROM [FlexPort].[dbo].[FlexPortJobQueueView]
WHERE [JobID] IS NOT NULL

'
IF ISNull(@JobScheduleID,'')<>''
Set @sql = @sql + ' And [JobScheduleID] like ''%' + @JobScheduleID + '%'''
IF ISNull(@JobID,'')<>''
Set @sql = @sql + ' And [JobID] like ''%' + @JobID + '%'''
IF ISNull(@JOBName,'')<>''
Set @sql = @sql + ' And [JobName] like ''%' + @JOBName + '%'''
IF ISNull(@Status,'')<>''
Set @sql = @sql + ' And [JobQueueStatus_ID] like ''%' + @Status + '%'''
If IsNull(@LastRunDateTime, '') <>''
Set @sql = @sql + ' And [LastRunDateTime] > ''' + Convert(varchar, @LastRunDateTime, 101) + ''''


Exec master.dbo.sp_ExecuteSql @sqlI have the following sproc that gets all the items from a queue with a few filters. I however need to return records where jobstepId is 1 and job jobqueuestatusid to be 4 if any jobqueuestatusid was 4 for that jobscheduleid, 2 if any is 2, and lastly 1. I tried inserting a
case when exists(select * from flexportjobqueueview where jobscheduleID = [jobscheduleID] and jobqueuestatusid = '4'
then 4,
else ..... then 3,
else ....... then 1,
end

that did not seem to work. It inserted 4 or 3's for all and not just the particular scheduleid. Any help on this will be great thanks
Ludwig

CREATE TABLE #QTEMP(
[JobQueueID][int],
[JobScheduleID][int],
[JobID][int],
[JobName][varchar](50),
[JobDesc][varchar](50),
[JobStepID][int],
[JobStepName][varchar](50),
[JobStepDesc][varchar](50),
[JobStepExecutable][varchar](100),
[JobQueueStatus_ID][int],
[JobQueueStatusDesc][varchar](100),
[NextRunDateTime][datetime],
[LastRunDateTime][datetime],
[ProcessID][int]
)ON[PRIMARY]
Declare @sql nvarchar(4000)
Set @sql='INSERT INTO #QTEMP
SELECT [JobQueueID],
[JobScheduleID],
[JobID],
[JobName],
[JobDesc],
[JobStepID],
[JobStepName],
[JobStepDesc],
[JobStepExecutable],
[JobQueueStatus_ID],
[JobQueueStatusDesc],
[NextRunDateTime],
[LastRunDateTime],
[ProcessID]
FROM [FlexPort].[dbo].[FlexPortJobQueueView]
WHERE [JobID] IS NOT NULL

'
IF ISNull(@JobScheduleID,'')<>''
Set @sql = @sql + ' And [JobScheduleID] like ''%' + @JobScheduleID + '%'''
IF ISNull(@JobID,'')<>''
Set @sql = @sql + ' And [JobID] like ''%' + @JobID + '%'''
IF ISNull(@JOBName,'')<>''
Set @sql = @sql + ' And [JobName] like ''%' + @JOBName + '%'''
IF ISNull(@Status,'')<>''
Set @sql = @sql + ' And [JobQueueStatus_ID] like ''%' + @Status + '%'''
If IsNull(@LastRunDateTime, '') <>''
Set @sql = @sql + ' And [LastRunDateTime] > ''' + Convert(varchar, @LastRunDateTime, 101) + ''''


Exec master.dbo.sp_ExecuteSql @sql

View 4 Replies View Related

Add Cases To Select Statment

Jun 8, 2006

I need to add some cases to the select statment for cpeorderstatus:
Here is my Select statement:
"SELECT O.ORDERID, C.FIRSTNAME, C.LASTNAME, O.CLIENTORDERID AS CRMORDERID, TO_CHAR(O.ORDERDATE, 'YYYYMMDD')                   AS CPEORDERDATE, TO_CHAR(O.SHIPDATE, 'YYYYMMDD') AS SHIPDATE, O.TRACKINGNBR AS TRACKINGNUMBER, O.SHIPNAME AS CARRIER,                  OI.ITEM AS CPEORDERTYPE, OI.QTY,       O.STATUS AS CPEORDERSTATUS, OSN.ORD_SERIAL_NO AS SERIALNUMBER, C.BTN AS BTN, C.FIRSTNAME AS FIRST, C.LASTNAME AS LAST,       C.SHIPADDR1 AS ADDRESSLINE1, C.SHIPADDR2 AS ADDRESSLINE2, C.CITY AS CITY, C.STATE AS STATE, C.ZIP AS ZIP, TO_CHAR(R.ISSUEDATE,       'YYYYMMDD') AS ISSUEDATE, R.RMA_ID AS RMANUMBER, R.RMA_REASON AS REASON, TO_CHAR(R.RETURNDATE, 'YYYYMMDD') AS RETURNDATE     FROM  SELF.ORDERS O, SELF.CUSTOMER C, SELF.ORDERITEM OI, SELF.ORD_SERIAL_NUMBER OSN, SELF.RMA R     WHERE O.CUSTID = C.CUSTID AND O.ORDERID = OI.ORDERID AND O.ORDERID = OSN.ORDER_ID (+) AND O.ORDERID = R.ORDER_ID (+) AND       (C.CUSTID IN (SELECT C.CUSTID FROM SELF.CUSTOMER C WHERE C.BTN='{0}')) ORDER BY O.ORDERDATE DESC"
I need to add multiple cases to cpeorderstatus, five different cases. Cane anyonye HELP

View 1 Replies View Related

Add Cases To My Select Statement

Jun 8, 2006

I need to add some cases to the select statment for cpeorderstatus:

Here is my Select statement:

"SELECT O.ORDERID, C.FIRSTNAME, C.LASTNAME, O.CLIENTORDERID AS CRMORDERID, TO_CHAR(O.ORDERDATE, 'YYYYMMDD')
AS CPEORDERDATE, TO_CHAR(O.SHIPDATE, 'YYYYMMDD') AS SHIPDATE, O.TRACKINGNBR AS TRACKINGNUMBER, O.SHIPNAME AS CARRIER,
OI.ITEM AS CPEORDERTYPE, OI.QTY,
O.STATUS AS CPEORDERSTATUS, OSN.ORD_SERIAL_NO AS SERIALNUMBER, C.BTN AS BTN, C.FIRSTNAME AS FIRST, C.LASTNAME AS LAST,
C.SHIPADDR1 AS ADDRESSLINE1, C.SHIPADDR2 AS ADDRESSLINE2, C.CITY AS CITY, C.STATE AS STATE, C.ZIP AS ZIP, TO_CHAR(R.ISSUEDATE,
'YYYYMMDD') AS ISSUEDATE, R.RMA_ID AS RMANUMBER, R.RMA_REASON AS REASON, TO_CHAR(R.RETURNDATE, 'YYYYMMDD') AS RETURNDATE
FROM SELF.ORDERS O, SELF.CUSTOMER C, SELF.ORDERITEM OI, SELF.ORD_SERIAL_NUMBER OSN, SELF.RMA R
WHERE O.CUSTID = C.CUSTID AND O.ORDERID = OI.ORDERID AND O.ORDERID = OSN.ORDER_ID (+) AND O.ORDERID = R.ORDER_ID (+) AND
(C.CUSTID IN (SELECT C.CUSTID FROM SELF.CUSTOMER C WHERE C.BTN='{0}')) ORDER BY O.ORDERDATE DESC"

I need to add multiple cases to cpeorderstatus, five different cases. Cane anyonye HELP

View 1 Replies View Related

Where Clause With Multiple Cases

Nov 28, 2012

I have a table with a field that contains an integer which represents the state of a record. This field "intType" may contain values 0-4.

A parameter in my stored procedure "@intUserType" may contain values 0-3

If @intUserType = 0, I need to select the records where intType = 0 or 3 but if @intUserType = 3, I need to return all records where intType > 1, all other values of @intUserType should return no records

The query I am working with seems a bit forced and I feel like it could be simplified, but I can't seem to wrap my head around it.

This is what I am working with:

Code:
SELECT * FROM tblEmployees
WHERE (intType = (CASE WHEN @intUserType = 0 THEN 0 ELSE NULL END)
OR intType = (CASE WHEN @intUserType = 0 THEN 3 ELSE NULL END)
OR intType > (CASE WHEN @intUserType = 3 THEN 1 ELSE NULL END))

Maybe it is as good as it needs to be ... I don't know .. I've only been using SQL regulary for a couple of months and I have not had the time to really study it in depth.

View 4 Replies View Related

Query-SubQuery And Cases

Oct 22, 2007

Hi everyeone,

do you know if I can do the following task through a single query

TableA(LocID,LocNAME)
TableB(ID,LocID,Amount)

What i need to do is to add sum amount having same locID from TableB and get LocIDs name through TableA.LocName. In the query there should be one thing more, if amount is less than zero put it into credit column, while if positive, puts in debit column

Thus Result(LocId, LocName, Debit, Credit) is the requied structure.
Can anyone help me out. I m not getting how to get the LocName if gets the sum by Groupby LocID also applying condition is confusing me:s

Looking forward for response
take care :)

View 4 Replies View Related

Are IN Statements Allowed In CASEs..?

Nov 27, 2007

For example I have


CASE (a.t_id)
WHEN (a.t_id in (22,23,27,30,38))
THEN t.desc
ELSE 'N/A'
END 'Column name..',



and that is giving me "incorrect syntax near 'in'" ??

View 20 Replies View Related

Selecting The Most Recently Edited Item AND Selecting A Certain Type If Another Doesn't Exist

Sep 20, 2007

I've got a big problem that I'm trying to figure out:
I have an address table out-of-which I am trying to select mailing addresses for companies UNLESS a mailing address doesn't exist; then I want to select the physical addresses for that company. If I get multiple mailing or physical addresses returned I only want the most recently edited out of those.

I don't need this for an individual ID select, I need it applied to every record from the table.

My address table has some columns that look like:
[AddressID] [int]
[LocationID] [int]

[Type] [nvarchar](10)
[Address] [varchar](50)
[City] [varchar](50)
[State] [char](2)
[Zip] [varchar](5)
[AddDate] [datetime]
[EditDate] [datetime]

AddressID is a primary-key non-null column to the address table and the LocationID is a foreign key value from a seperate Companies table.
So there will be multiple addresses to one LocationID, but each address will have it's own AddressID.

How can I do this efficiently with perfomance in mind???

Thank you in advance for any and all replies...

View 2 Replies View Related

Deleting Dupes In Special Cases

Feb 7, 2005

I need to delete all rows that match at least one of the account_id values of another row *and* that has the same email address. However, if they have the same email address and none of the account_id values then I need to keep it. I've attached a sample dataset along with the expected results.

I have this:
DELETE [acctID_emailAddress_tmp] FROM [acctID_emailAddress_tmp]
JOIN
(select emailaddress, account_id, max(contact_id_tmp) max_cid
from [acctID_emailAddress_tmp]
group by emailaddress, account_id) AS tempImportTable
ON tempImportTable.[emailaddress] = [acctID_emailAddress_tmp].[emailaddress]
WHERE [acctID_emailAddress_tmp].[contact_id_tmp] < tempImportTable.[max_cid]
AND tempImportTable.[account_id] = [acctID_emailAddress_tmp].[account_id];

but it doesn't work since it's keeping the subset of the dupe row(s).

Can someone shed some light?

TIA

View 14 Replies View Related

Finding Cases With All Children Closed

Jan 5, 2013

Finding the court cases where all children associated with that case have a programClosureDate. I can run this query:

CaseInfo Table
CaseID,
CaseNumber,
CaseName

CaseChild Table
CaseID, FK to CaseInfo
ChildPartyID, FK to PartyID in Party table
ProgramClosureDate

Party Table
ID,
PartyID,
Firstname,
LastName

SELECT ci.CaseNumber, ci.CaseName, p.firstname+' '+p.lastname AS child, cc.programClosureDate
FROM CaseInfo ci JOIN
CaseChild cc ON ci.CaseID = cc.CaseID JOIN
Party p ON cc.ChildPartyID = p.PartyID

WHERE cc.ProgramClosureDate IS NOT NULL
ORDER BY ci.CaseName

But this does not give me the cases where all the children have programCLosureDate IS NOT NULL.

View 5 Replies View Related

Like Clause - Preventing Multiple Cases

Sep 9, 2013

I have a like clause like this:

WHERE COLUMN LIKE CAT1%
or
COLUMN LIKE CAT2%
or
COLUMN LIKE CAT3%
ETC..

I want to know if it is possible just have one like clause from 1-9:

CAT1, CAT3, ...., CAT9

View 3 Replies View Related

Cases Supporting A Particular Association Rule

Jun 18, 2007

I haven't been able to find a DMX query which will spit out the cases which support a particular association rule. I was hoping it would work sort of like drillthrough but show only the cases supporting a particular rule. Am I missing something?



What I ended up doing was extracting the itemsets of the rule from the model's content then running a SQL query to retrieve the cases that contain both the left-hand and right-hand itemset of the rule. I'm hoping there's a better way.

View 1 Replies View Related

Custom Logger Doesn't Work In Certain Cases

May 10, 2007



I am testing a set of SSIS packages, In order to test my SSIS packages for errors I have two negative test cases



1) I didn't provide checkpoint file for the checkpoint enabled package.

2) I provide a wrong configuration file



Even though I am using a script task in my "on error" event of my SSIS package. It is not executed. (Perhaps because the package doesn't even execute).



My problem is that SSIS itself puts just a simple one liner in windows event log "Package Failure Error". It does not provide which package failed, why it failed etc. Therefore the admin who gets the ticket to resolve the issue has no clue of what is going wrong and where!



Since my custom logger doesn't even run, I don't know how can I put more details into the windows event log.



How can I resolve this?



regards,

Abhishek.

View 3 Replies View Related

Can SendStringParametersAsUnicode=false Be Overriden/changed For Certain Cases

Sep 4, 2007

Configuration: MS SQL server 2005 SP2, and MS jdbc driver version: 1.1
The sendStringParameterAsUnicode has been set to false for performance reasons. However, when inserting unicode data, we would like to override the setting and send the data encoded in unicode, instead of defaulting the whole app to unicode=true and take a performance hit.

Any suggestions? We have tried the cast(? as nvarchar) function, but that did not help.

Sample code/output:
String text = "u0143u0144";
sendStringParametersAsUnicode=false
insert into unitable (_ntext) values (?)
Inserting into databse:
143 144 (printed hex values)
Read from database:
3f 3f (printed hex values)

View 6 Replies View Related

CLR UDAGG Returns Severe Error On Certain Cases

Jun 18, 2007

Hi peoples,



I have created a custom CLR user define aggregate function based on the example that i found at http://msdn2.microsoft.com/en-us/library/ms131056(SQL.90).aspx.

It works great until i discovered that it will failed if i try to do either one of the following:

query a large records e.g: more than 4k records
has IS NULL in my where clause e.g: WHERE myConcatenatedFld IS NULL

Other than these two, it works perfectly fine.



Here is the error that i got:



Msg 0, Level 11, State 0, Line 0

A severe error occurred on the current command. The results, if any, should be discarded.



I have attached the Concatenate class that i used in my UDAGG.






Code Snippet

using System;

using System.Data;

using System.Data.SqlClient;

using System.Data.SqlTypes;

using Microsoft.SqlServer.Server;

using System.IO;

using System.Text;



[Serializable]

[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(

Format.UserDefined, //use custom serialization to serialize the intermediate result

IsInvariantToNulls = true, //optimizer property

IsInvariantToDuplicates = false, //optimizer property

IsInvariantToOrder = false, //optimizer property

MaxByteSize = 8000) //maximum size in bytes of persisted value

]

public class Concatenate : IBinarySerialize

{

/// <summary>

/// The variable that holds the intermediate result of the concatenation

/// </summary>

private StringBuilder intermediateResult;

private const int MAX_STRING_LEN = 4000;

/// <summary>

/// Initialize the internal data structures

/// </summary>

public void Init()

{

this.intermediateResult = new StringBuilder();

}

/// <summary>

/// Accumulate the next value, not if the value is null

/// </summary>

/// <param name="value"></param>

public void Accumulate(SqlString value)

{

//Dont do anything if the input is null or empty

if (value.IsNull || value.Value.Length == 0)

{

return;

}

//Skip concatenation if the output exceed 4000 chars

if (this.intermediateResult.Length + value.Value.Length > MAX_STRING_LEN)

{

return;

}

//Concatenate output

if (!this.intermediateResult.ToString().Contains(value.Value.Trim()))

this.intermediateResult.Append(value.Value.Trim()).Append(", ");

}

/// <summary>

/// Merge the partially computed aggregate with this aggregate.

/// </summary>

/// <param name="other"></param>

public void Merge(Concatenate other)

{

//Skip concatenation if the output exceed 4000 chars

if (this.intermediateResult.Length + other.intermediateResult.Length > MAX_STRING_LEN)

{

return;

}

//Concatenate computed output

this.intermediateResult.Append(other.intermediateResult);

}

/// <summary>

/// Called at the end of aggregation, to return the results of the aggregation.

/// </summary>

/// <returns></returns>

public SqlString Terminate()

{

string output = string.Empty;

//delete the trailing comma, if any

if (this.intermediateResult != null

&& this.intermediateResult.Length > 0)

{

output = this.intermediateResult.ToString(0, this.intermediateResult.Length - 2);

}

return new SqlString(output);

}

public void Read(BinaryReader r)

{

intermediateResult = new StringBuilder(r.ReadString());

}

public void Write(BinaryWriter w)

{

w.Write(this.intermediateResult.ToString());

}

}





Anyone has any idea on how to solve this issue?. Thanks

View 5 Replies View Related

How To Count Cases For Different Groups Based On Different Criteria

Apr 25, 2008



Hello,

I need to create a query that will count new cases based on the create date(create_date) and criteria for the groups(The only way to distinguish between the 2 major groups mts and bnb is area!= 'bnb" because everything else is MTS). The sample report I need to create below shows how it needs to be counted weekly, for a 4 month period, for the groups under MTS and BNB. The totals and grand totals can be achieved in the report tool. I want to create variables for the new cases (mts_newcases_sales, mts_newcases_salesd, bnb_newcases_salesd etc)

Ex. MTS sales : (status = 'Calculated' OR status = 'REJECTED') and errorsource != 'marketing' and accountns is null and area != 'BNB'(everything else is MTS)

MTS salesd ; Credit >= '1001' and (status = 'REJECTEDV' or status = 'ACCEPTEDS') and errorsource != 'marketing' and accountnr is null

BNB creditr: Credit < 101 and (status = 'SUBMITTED' OR status = 'REJECTEDS' OR status = 'REJECTEDA' OR STATUS = 'ACCEPTEDC')








12-Jan

19-Jan

26-Jan

2-Feb

9-Feb

16-Feb



MTS





















New Cases Received

85

84

79

98

79

95



Sales

30

32

27

40

42

38



SalesD

47

34

37

23

23

37



CreditR

44

29

26

35

55

54



CreditB

6

12

9

5

7

13



CreditS

-

-

-

-

3

-



CreditP

10

11

11

24

17

7



MTS Subtotal

140

125

110

144

151

150

























BNB





















New Cases Received

12

13

14

14

6

11



Sales

-

-

-

-

-

-



SalesD

-

-

-

-

-

-



CreditR

12

11

12

10

5

9



CreditB

8

13

9

17

16

6



CreditS

-

-

2

-

-

-



CreditP

1

1

1

1

4

3



BNB Subtotal

21

25

24

28

26

19

























Total





















New Cases Received

97

97

93

112

85

106



Sales

30

32

27

40

42

38



SalesD

47

34

37

23

23

37



CreditR

56

40

38

45

60

63



CreditB

14

25

18

22

23

19



CreditS

-

-

2

-

3

-



CreditP

11

12

12

25

21

10



Grand Total

161

150

134

172

177

169



This is just a very brief bit of code

SELECT MTS_new_cases_sales, mts_new_cases_salesd €¦€¦.

FROM vwCreditN
WHERE mts_sales_new_cases = ( )...
and (status = 'Calculated' OR status = 'REJECTED')...



Can you please show me how to accomplish this?

Thank you in advance for your effort,



Rhonda

View 2 Replies View Related

Practical Cases Of Good Dsatabase Designs

Jan 17, 2008

Hi,
is there any website or book that provide excellent database design examples to learn?

Appreciate for any help
Ricky.

View 1 Replies View Related

Mining Model Predicts Same Set Of Products For All Cases

Sep 4, 2006

Hi

I have developed a product
basket mining model as follows



DSV



SELECT C.CustomerId,C.CustomerIdName,P.ProductId,P.ProductIdName

FROM Customer INNER
JOIN CustomerProduct

ON C.OpportunityId
= P.OpportunityId



Mining Structure



CREATE MINING MODEL ProductBasket

(

CustomerId
TEXT KEY,

CustomerIdName
PREDICT,

ProductId
PREDICT,

ProductRecommend
TABLE PREDICT

(


ProductId TEXT KEY


ProductIdName PREDICTONLY

)

)

USING Microsoft_Association_Rules







Prediction Query


Since I want the output in the following format



Product
ID
Items (nested Table)

Product
A
product B

Product C



Product
B
Product A

Product C





I have written the prediction query as follows



SELECT


t.[ProductId],


PredictAssociation([Association].[ ProductId],3)

From


[Association]

PREDICTION JOIN


OPENQUERY([Adventure Works Cycle MSCRM],


'SELECT DISTINCT

[ProductId]

FROM

(SELECT ProductId FROM ProductBase)
as [Product]

') AS t

ON



[Association].[Product Id] = t.[ProductId]




The model is predicting the
same set of products for every case. Even changes in the algorithm parameter
value do not have any impact on the result.

What is the reason for this and
how can u rectify it?

View 5 Replies View Related

Transact SQL :: BETWEEN Using String Dates Doesn't Work In Some Cases

Sep 21, 2015

I put this series of select statements to verify that the BETWEEN statement is working properly. I should always get “Between” below.

SELECT
CASEWHEN'1/1/15'BETWEEN'1/1/15'AND'1/31/15'THEN'Between'ELSE'Not
Between'END
SELECT
CASEWHEN'1/31/15'BETWEEN'1/1/15'AND'1/31/15'THEN'Between'ELSE'Not
Between'END

[Code] .....

View 4 Replies View Related

SQL Server 2008 :: Query To Looking For Cases Of Period Difference In Legal Names

Jun 9, 2015

How to write a Query for multiple legal names that have the same CARE Number (same address) with difference of one Legal Name having a period in the name versus the other legal name that doesn't.

For example: Looking for cases of two of the same legal name one set off by period

All Season Equipment Ltd.
All Season Equipment Ltd

West End Housing, Inc.
West End Housing, Inc

Wellings, Norman L.
Wellings, Norman L

North Texas Boats, LLC
North Texas Boats, L.L.C.

Oktibbeha County Cooperative (A.A.L.)
Oktibbeha County Cooperative (AAL)

S & R Turf & Irrigation Equipment, L.L.C
S & R Turf & Irrigation Equipment, L.L.C.

Burke Equipment Company; Burke Equipment-Seaford, Inc.; Newark Kubota, Inc.
Burke Equipment Company
Burke Equipment-Seaford, Inc.

Pleasant Valley Outdoor Power, L.L.C.
Pleasant Valley Outdoor Power, LLC

J & D Lawn and Tractor Sales, Inc.
J&D Lawn & Tractor Sales, Inc"

View 2 Replies View Related

Problems Predicting Unseen Cases Of Nested Tables Data Mining Models

May 27, 2007

Lets take the following example:



Movie train table:
ID Class
1 +
2 +
3 -
4 +
5 -



Actor train nested table:
ID MovieID Gender
1 1 F
2 1 M
3 1 F
4 1 F
5 2 M
6 2 M
7 2 F
8 3 F
9 3 F
10 4 M
11 4 M
12 4 F
13 4 F
14 5 F
15 5 M



We want to build a classifier model in order to predict the Class of a Movie based on the Gender of movie's actors. To deal with the nested table Analysis Services maps each record of the nested table to an attribute of the case table. These attributes are named Actor(n).Gender with n = 1..15, and so they are dependent on the nested table record numbers. Both Microsoft Decision Trees and Microsoft Naive Bayes algorihms use these attributes without any modification.



We are implementing a Relational Naive Bayes algorithm and we are planning to aggregate such attributes in order to make them independent of the nested table record numbers.


Next step we tried to predict some unseen cases and here we face with
a very huge problem.


Lets take more two tables of unseen cases:



Movie test table:
ID Class
6 +
7 NULL
8 NULL



Actor test nested table:
ID MovieID Gender
1 6 F
2 6 M
3 6 F
4 6 F
16 7 F
17 7 M
18 7 F
19 7 F
20 7 F
21 8 M
22 8 M
23 8 F



Predicting the movie 6 Class is not a problem since the movie actors were included in the training dataset and when the records are mapped to attributes because they already exist in the model. But when you
try to predict movies (7 an 8) with unseen actors all new attributes are simply ignored in the ALGORITHM:redict call (in_ulCaseValues is zero!) because they do not exist in the model!



What is the solution?

View 3 Replies View Related

SQL Server 2012 :: Calculate Failure Rates Of Systems Based On Cases Opened Through Support

Jun 5, 2014

I am trying to build a query which will be used in an automated report to calculate failure rates of systems based on cases opened through support. Here is where I am stuck. Some systems may have multiple cases opened within the same span of another cases however we would consider this one failure:

System ACase12013-07-11 13:17:09.0002013-07-15 12:05:03.000
System ACase22013-07-12 16:27:50.0002013-07-12 16:29:12.000
System ACase32013-07-12 17:30:32.0002013-07-12 17:40:11.000
System ACase42013-07-12 19:00:24.0002013-07-12 19:04:14.000
System ACase52013-10-01 18:02:23.0002013-10-01 18:11:26.000

Lets say System A generated those 5 cases however Case 2,3 and 4 all happened within the same period as Case 1 so those 4 cases should count as one failure so my end result should be

System ACase12013-07-11 13:17:09.0002013-07-15 12:05:03.000
System ACase52013-10-01 18:02:23.0002013-10-01 18:11:26.000

And that system should show me 2 failures. I was thinking of using a temp table but not sure if that is possible as I am stumped on how to compare the dates to be able to validate if they fall within the range of an older case and whether or not to include them into the new Temp Table.

View 8 Replies View Related

Smalldatetime

Mar 4, 2004

im getting this error while inserting into table (description of table given below)

mytable
mycode smallint identity,
mydataitem varchar(100),
mydatefrom smalldatetime,
mydateto smalldatetime,
myopcode smallint,
lastupdate smalldatetime

my sql statement was

INSERT INTO mytable
(mydataitem,mydatefrom,mydateto,myopcode,lastupdat
e)
VALUES
('SAMPLEDATA','01/01/2003','18/05/2003',1,'05/Mar/2004')

THE ERROR RETURNED IN MY CLIENT APP IS
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

AND THAT IN QA IS

Server: Msg 296, Level 16, State 3, Line 1
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
The statement has been terminated.

can ne 1 point out the mistake in my sql statement ?


__________________
Cheers....

baburajv

View 4 Replies View Related

Using Smalldatetime

Jul 3, 2007

I have an Execute SQL Task that pulls the max date from a sql table.

SELECT max(date_Idx) FROM dbo.FactDailyInventorySnapshot



This field is defined as a smalldatetime. I want to store this max date in a variable in SSIS called LastDate.



Then in a data flow, in an OLE DB Source, I want to use it as a parm in a sql command to compare to a smalldatetime field.



My question is, what type of variable do I declare it in in SSIS, and what is the correct parameter mapping inside of my sql query? I thought I had exhausted all combinations of variable types and parameter types. I have even tried casting it as different data types when I do the exec sql task of getting the max date. Any help would be appreciated. Thanks!

View 1 Replies View Related

Datetime To Smalldatetime

Jul 14, 2006

I need to convert a datetime field to smalldatetime.
This particular field we only care about the time portion (an example would be '1899-12-30 13:15:00.000')
For now I created another field say 'newTime' that is smalldatetime, in which I want to "update" to the smalldatetime version of the data.  I know this will truncate the ms, but I don't care about that.  Also the min date that can be used with smalldatetime is Jan 1 1900.
Not sure how to go about doing this.

View 3 Replies View Related

From Datetime To Smalldatetime

Mar 30, 2000

Hi guys!
I need to convert datetime data type to smalldatetime on production
server with hundreds transactions per minute. In this case do I need to restrict users access to the table or put table in the single user mode?
Or it doesn't have any impact on productivity and I just can open Design table window in SQL Enterprise Manager and edit it?
Thank you in advance,
Igor

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved