Viewing 15 posts - 3,511 through 3,525 (of 10,144 total)
It's an old thread, Wesley - so it's quite likely that none of the respondents will reply. Are you experiencing a similar issue? If so, your best option might be...
March 21, 2014 at 4:43 am
Check your table aliases:
SELECT s.state_name
, COUNT(DISTINCT DUPS.PermitNumber) AS NumOfDupPermits
, SUM(DistinctPermits) AS DistinctPermits
FROM States S
CROSS APPLY (
SELECT w.StateID, COUNT(*) as DistinctPermits
FROM Permit P
INNER JOIN Well W1 ON P.WellID...
March 21, 2014 at 3:28 am
rlsublime (3/20/2014)
(Select sum(NVL(sh_productivehours,0))
...
March 21, 2014 at 2:51 am
Here's a sandpit version very similar to what you currently have. The only downside is the ugly aggregate - but it's a very simple ugly aggregate. I guess it depends...
March 20, 2014 at 9:56 am
Can you augment the sample table in my last post to account for your observations? Thanks.
March 20, 2014 at 9:04 am
SQL Server will apply the filter and the conversion in whichever order results in the lowest cost - and in this case, the order chosen is breaking your query. Here's...
March 20, 2014 at 7:50 am
You're welcome, thanks for the feedback.
March 20, 2014 at 7:22 am
There are loads of ways of doing this. Here are two.
drop Table #Sample
Create Table #Sample (ID int not null primary key, RefID int , SeqNo int , Name varchar(10) ...
March 20, 2014 at 4:46 am
The numeric test and the cast to bigint have to occur together and in the correct order.
CREATE VIEW ChildEmployees
AS
SELECT x.EmpID
FROM MasterEmployees
CROSS APPLY (
SELECT EmpiD CASE
WHEN ISNUMERIC(EmpID) =...
March 18, 2014 at 10:47 am
Here's a solution which will work with many values. First the UDF:
ALTER FUNCTION fn_BITWISE_OR
(
@col1 VARCHAR(3)
)
RETURNS VARCHAR(3)
AS
BEGIN
-- try row-wise
DECLARE @LastValue INT
SELECT @LastValue = 000
SELECT @LastValue = @LastValue | d.bit_flag
-- substitute...
March 18, 2014 at 10:10 am
joakim.fenno (3/18/2014)
CREATE TABLE my_table (col1 nvarchar(25) NULL, bit_flag nvarchar(3) NULL)
INSERT INTO my_table VALUES('A', '100'), ('A', '001'),('B', '010'),('A', '001');
expected output from query :
A 101
B 011
The bit_flag column contains 12 flag (and...
March 18, 2014 at 9:46 am
Although just about every reference on the first page returned by Google specifies two operands, the TSQL BITWISE OR actually works with a chain like this:
-- on a single...
March 18, 2014 at 9:36 am
joakim.fenno (3/18/2014)
ChrisM@Work (3/18/2014)
joakim.fenno (3/18/2014)
ChrisM@Work (3/18/2014)
If you can guarantee that your aggregate function would always and only ever generate the two values required by BITWISE OR, then you will find it...
March 18, 2014 at 9:25 am
joakim.fenno (3/18/2014)
ChrisM@Work (3/18/2014)
If you can guarantee that your aggregate function would always and only ever generate the two values required by BITWISE OR, then you will find it far far...
March 18, 2014 at 9:12 am
joakim.fenno (3/18/2014)
But the function needs to work as an aggregate function.
I have to be able to execute...
March 18, 2014 at 8:53 am
Viewing 15 posts - 3,511 through 3,525 (of 10,144 total)