Viewing 15 posts - 751 through 765 (of 1,193 total)
Perhaps this?
CREATE TABLE #Numbers (ID int, Number int)
INSERT INTO #Numbers
VALUES (1,20),(2,11),(3,20),(4,8),(5,11),(6,4)
SELECT number, COUNT(*) AS NumberCount
FROM #Numbers
GROUP BY Number
ORDER BY NumberCount desc, MIN(ID) asc
DROP TABLE #Numbers
Cheers!
December 10, 2015 at 10:47 am
It could be the issue Luis pointed out, or it could be something else, like your data not matching what we're guessing it looks like.
If you could provide a sample...
December 9, 2015 at 8:48 am
Something like this?
CREATE TABLE#alpha_numerics(alpha_numeric VARCHAR(30))
INSERT INTO#alpha_numerics
VALUES ('234'),
('23f5'),
('7689'),
('Hey!'),
('58-Fr')
SELECT*
FROM#alpha_numerics
WHEREalpha_numericNOT LIKE '%[^0-9]%'
DROP TABLE#alpha_numerics
Cheers!
December 8, 2015 at 3:53 pm
I assume FeedName is the name of a column in Alert.Export_Files.
Check out the cautionary notes here: https://technet.microsoft.com/en-us/library/ms178050(v=sql.105).aspx
This is a common source of confusion, and an excellent reason to explicitly...
December 7, 2015 at 7:18 pm
Those dates in my earlier query weren't binary.
Since you didn't say what data types any of the columns were and your sample data only showed dates (no times), I created...
December 7, 2015 at 3:00 pm
Your adaptation of the query to your actual data must have changed it, then, because the query I provided does not behave that way with your sample data.
You'll have to...
December 7, 2015 at 2:19 pm
The SELECT I have in there is code to do it without a temp table.
I create a temporary table and populate it with your sample data so it is in...
December 7, 2015 at 12:12 pm
Perhaps something like this?
CREATE TABLE #Temp (code CHAR(2), code_status CHAR(20), code_date DATE);
INSERT INTO #Temp
VALUES
('AA','Infringed', '20150101'),
('AA','Not Infringed', '20150102'),
('BB','Infringed', '20150105'),
('BB','Not Infringed', '20150105'),
('CC','Infringed', '20150110'),
('CC','Not Infringed', '20150101'),
('CC','Not Infringed', '20150110');
SELECT code FROM #Temp
GROUP BY...
December 7, 2015 at 11:43 am
Perhaps this?
SELECT*
FROMdbo.abc_sort
ORDER BYCASE
WHEN IDNUMBER = 2 THEN ID1
ELSE ID2
END,
name ASC
--IDNUMBER DESC also works for the secondary sort in the sample data
;
The logic seems strange to me, but...
December 7, 2015 at 11:17 am
yakko_Warner (12/2/2015)
cory.bullard76 (12/2/2015)
Ok, it is a date time field type....and I show records for Dec 1 2015.....but, when I say that field = 12/01/2015 I get 0 results
Where somedatetimefield >=...
December 2, 2015 at 1:07 pm
Try the DBCC PAGE using dump style 3 instead of 0, 1,or 2. I think that's the catch.
Cheers!
December 2, 2015 at 9:53 am
Thanks!
Remember, to SQL Server, the queries are not the same. Without the IF, the query is asking for the actual count of rows from the view that meet the WHERE...
December 1, 2015 at 6:54 pm
As pointed out in the article I posted, beginning in SQL Server 2005, the optimizer converts IF (SELECT COUNT...)>0 to an EXISTS under the covers, so I would expect...
December 1, 2015 at 3:21 pm
In addition to what Sean said, the execution plans for the queries would be good to have as well.
Beginning in SQL Server 2005, the optimizer converts IF (SELECT COUNT...)>0 to...
December 1, 2015 at 2:50 pm
The INNER JOINs to both aliased versions of #TEST are joining on equality with the TestID from #Patient, which means each row will have the same Test (either Potassium or...
December 1, 2015 at 12:32 pm
Viewing 15 posts - 751 through 765 (of 1,193 total)