bborrisov:
Grr! My code example is right but I miss typed the statment after the code - sorry for the confusion there!
gmmastros:
adding the min() solves the problem - thanks for the tip!
Now, if I understand what's going on in this code... the select statement is checking oC.Id and oC.Fld2 to...
Thanks for the reply borrisov, I appologize for the slow reply!
The code you gave me fullfills points 1, and 2 in my question, but I'm still not sure how to take care of point three.
By adding a fourth record to the @orders_historical table the query returns a duplicate Fld2 value. How do I...
The select statement I'm using to create my view has about 4 joins to get to various files that I need, however, there are two main files that I am pulling data from. One is the orders_current [ oC ] and the other is orders_historical [ oH ].
Here's what I need to do:
If I find a record in [...
I'm not sure how they are bringing the data in... that's part of the problem. We're going to schedule another meeting to talk with them about this and other issues.
Thanks again for all your help,
Steve
Thanks for the responses - sorry my reply is so slow!
gmmastros - I like that Idea, I think I'll implement the Nullif code. It will help shorten my current t-sql a bit and teach me a new trick at the same time! :0)
Alex - from what I've seen, you are correct, the datetime format always gives...
Thanks for taking a look at my question.
I'm sending data to corporate for analysis by their programmers, However, this past Friday I received the following email (emphasis supplied by me).
Here's the problem:
The code I'm using was nicely provided by gmmastros over on Link: this thread...
I should also mention that removing the wildcard character (in blue) does not change the results.
CASE
WHEN LEFT(C6B9CD, 2) LIKE '¿·' THEN REPLACE(C6B9CD, '¿·', '')
WHEN RIGHT(C6B9CD, 1) LIKE '}' THEN REPLACE(C6B9CD, '}', '')
ELSE C6B9CD
END AS SHIPTO_KEY
Hello Again,
I've got some special characters I need to strip out of a field but there are a few rows that do not seem to be affected.
Actually, I should say that I have it 90% working, but there are some records with a trailing curly bracket ( } ) that will not leave... *sigh*
Ok, here's a...
Try this...
CAST(AmountField AS DECIMAL(10,2)) AS AMOUNT
or
CAST(AmountField AS NUMERIC(10,2)) AS AMOUNT
I think that should do what you're looking for. Just change the (10,2) to whatever precision you need.
Cheers!
Thanks for the help guys!
I went through and found several gotchas, once I cleaned those up and CAST some of the fields to the required lengths the query works like it should.
ps - I really do apologize for such a long code post that's not normally my style, but it appears to have helped in...
Sorry, I wouldn't normally post this much code, but you asked for it... :0) It's fairly long, but here goes:
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME = 'ORDER_DATA_C')
DROP VIEW ORDER_DATA_C;
GO
CREATE VIEW ORDER_DATA_C
AS
SELECT /* OPEN ORDERS */...
Hello Everyone,
I'm trying to combine a view for current orders, and a view for historical orders. The view is created without error, but when I try to query the view I get the following error.
The interesting thing is that if I create the views (current / historical) seperatly the query works...
WARNING: LONG (AND WIDE) POST
It appears that the results are similar, although I didn't drop the tables each time because I uped the iterations to 150000, which gave me 2,849,981 million rows (closer to the particular view I'm working with).
Even though there were 2.8 million rows, the...
Thanks Alex,
This is actually going to be used in a view, more specifically on a zipcode column on a join in a view.
Confused yet... :0)
Here's the code I'm using
LEFT JOIN
ZIPFILE ZIPF
ON
MBAL.ALCPTX = ZIPF.CITY AND
LEFT(MBAL.ALCVCD, 5) = ZIPF.ZIP5
The column being trimmed to 5...
I'm working with a smallish recordset of just over 2 million records. In order to select the correct information, one of the select statements needs only the 5 leftmost characters.
Currently I'm using LEFT(col3, 5)
Does anyone have any advice as to which of the three methods would be faster...
Oops!
I was playing with your code to see what would happen if I took out one of the convert's.
the correct code should read...
,CASE
WHEN MBF9.FEGHNB = '0' THEN '0'
WHEN MBF9.FEGHNB <> '0' THEN CONVERT(VarChar(10), Convert(DateTime, Convert(VarChar(8), MBF9.FEGHNB + 19000000))...
You are quite correct, I found 3972 items where the original row value was '0'.
I used the following code to fix the problem, and hopefully this 'help request' is put to bed. ;0)
CREATE VIEW INVOICE_DATA
AS
SELECT
'LOCATION' AS BU_KEY
,CASE
WHEN MBF9.FEGHNB = '0' THEN '0'
WHEN...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.