Viewing 15 posts - 2,836 through 2,850 (of 3,957 total)
Jeff Moden (9/8/2012)
September 9, 2012 at 6:21 pm
Jeff Moden (9/7/2012)
You made the same mistake that I originally made. Try your code on the following test data and marvel at the pain of an accidental CROSS JOIN.
DECLARE...
September 7, 2012 at 8:12 pm
peter2501 (9/7/2012)
Yes, it works.Thanks, now I can dig into the script what it really does so I can also try to understand.
Thanks very much.
You're welcome.
A brief explanation:
The Tally table is...
September 7, 2012 at 3:45 am
peter2501 (9/7/2012)
Still not working with the newest queries I got, same error withe the group by clause (even twice this time)
Have you tried mine?
Note that I just made a quick...
September 7, 2012 at 3:10 am
In that case, this should work nicely for you:
DECLARE @Miview TABLE
(Username VARCHAR(20), Start DATETIME, Activity VARCHAR(20))
INSERT INTO @Miview
SELECT 'Tom', '2012-09-07 12:00', 'Logon'
UNION ALL SELECT 'Fred', '2012-09-07...
September 7, 2012 at 2:54 am
Perhaps something like this:
DECLARE @t TABLE (ID INT IDENTITY, strcol VARCHAR(20))
INSERT INTO @t
SELECT 'aa001' UNION ALL SELECT 'ab001'
UNION ALL SELECT 'aa001a0' UNION ALL SELECT 'aa001b0'
;WITH Tally (n) AS (
...
September 6, 2012 at 11:50 pm
swathi nareddy (9/6/2012)
CREATE FUNCTION SPLIT
(
@RowData nvarchar(2000),
@SplitOn nvarchar(5)
)
RETURNS @RtnValue...
September 6, 2012 at 11:38 pm
Try googling "SQL Crosstabs" or look at these articles from Jeff Moden:
http://www.sqlservercentral.com/articles/T-SQL/63681/
http://www.sqlservercentral.com/articles/Crosstab/65048/
If you provide sample data, I'm sure someone can provide you a working, tested solution from the DDL...
September 6, 2012 at 11:33 pm
Here is another way to return m/d format (mm/dd without leading 0s):
SELECT STUFF(REPLACE('/'+CONVERT(VARCHAR(5), YourDate, 101), '/0', '/'), 1, 1, '')
On the GROUP BY, I would use something like this to...
September 6, 2012 at 10:29 pm
If you have 0 logins on a day, do you want to show that date (with 0 unique logins) row?
September 6, 2012 at 10:12 pm
Lynn Pettis (9/6/2012)
September 6, 2012 at 8:12 pm
Tatsu (9/6/2012)
September 6, 2012 at 7:44 pm
Interesting problem. Fortunately I developed a script "UNIQUEnTuples" in this article that will help:
http://www.sqlservercentral.com/articles/sql+n-Tuples/89809/
First, while you did do a good job of showing your expected results, you should always...
September 6, 2012 at 7:40 pm
SQLTestUser (9/6/2012)
Logtable
ID Date ...
September 6, 2012 at 7:03 pm
chaseurpuli (9/6/2012)
September 6, 2012 at 6:42 pm
Viewing 15 posts - 2,836 through 2,850 (of 3,957 total)