Viewing 15 posts - 646 through 660 (of 3,489 total)
It's not that CAST doesn't work, it's that it's expensive, especially if you use it in a crazy place like a join.
August 5, 2020 at 12:41 am
It's easier than that.
select * from tblTest
where TestNumber = '20012';
August 4, 2020 at 11:58 pm
You're welcome... sorry it took me a bit to actually understand the question.
August 2, 2020 at 1:56 pm
(sorry, my internet is freaking out... double post).
August 2, 2020 at 1:47 am
I think this works... <g> Standard pattern is to do the TOP N inside the CROSS APPLY, and join the Cross Apply to the outer query. (that's what the tt.Month...
August 2, 2020 at 1:45 am
This looks like it works:
SELECT DISTINCT t.Company,sales.[Month], sales.Sales
FROM TestTable t
CROSS APPLY (SELECT TOP 5 *
FROM [TestTable] t2
WHERE t.Company = t2.Company
ORDER BY t2.Sales DESC) sales
ORDER BY t.Company, sales.Sales...
August 2, 2020 at 12:17 am
Oh, I see now... how about something like this:
CREATE TABLE Employee (
EmployeeKey INT IDENTITY PRIMARY KEY,
FirstNameVARCHAR(20) NOT NULL,
LastNameVARCHAR(20) NOT NULL,
ShiftNo TINYINT NOT NULL
);
-- both WelderID and OperatorID...
August 1, 2020 at 1:05 am
Well, I meant joining to that table twice and returning the two different employee names...
TB_EMP.EMP_INT AS "WELDER",
TB_EMP.EMP_INT AS "OPERATOR",
Oh wait... can't do that... because that's only one column in EMP...
August 1, 2020 at 12:22 am
Store the dates as datetime, not VARCHAR. Then you can just use DATEDIFF(minute,startdate, enddate)
Otherwise you have to cast the VARCHAR columns, and that'll cause the query to be really slow...
July 31, 2020 at 6:05 pm
Looks like you need two instances of TB_EMP to join on the welder key and another to join on the Operator key.
July 31, 2020 at 6:03 pm
Are you trying to create an aging query, so that each invoice is "binned" by age, which is determined by [DocDate]? (the usual is something like "less than 30 days",...
July 29, 2020 at 3:00 pm
Just to see if I could do it, I wrote some code to do the testing for me... <g>
I shamelessly stole Phil's checking code.... Seems to work, though.
July 22, 2020 at 6:34 pm
Steve,
Since it's only looking at column names and not rows of data, it seems this could be done easily with a little bit of dynamic SQL (just get a list...
July 22, 2020 at 4:22 pm
Maybe this and use it as a cursor so I can create the columns that way?
use tempdb;
GO
IF OBJECT_ID('tempdb..#Test2') IS NOT NULL DROP TABLE #Test2
CREATE TABLE #Test2
(A int,...
July 22, 2020 at 2:55 pm
Viewing 15 posts - 646 through 660 (of 3,489 total)