Viewing 15 posts - 46 through 60 (of 153 total)
Also just a quick note...I noticed that you are applying a filter to a table that you are left joining to. That will effectively turn your left join into an...
March 24, 2008 at 11:14 am
How about something like this:
Select c.ConsultantID
,c.UserXID
...
March 24, 2008 at 11:09 am
Your issue is one of scoping.
You can't reference a field joined to in outer query in the inner query.
When working with derived tables, get your inner query working independent of...
March 21, 2008 at 1:04 pm
Thanks for the feedback! I can sympathize with your situation. It is never easy getting dumped on, especially with SQL. I come from a procedural programming background, and the set...
March 21, 2008 at 10:04 am
alorenzini (3/21/2008)
One more quick question. for the column Name (eg. JAN) I would like to format as...
March 21, 2008 at 9:47 am
OK. A few things here:
No need to sub query to pull out a description, and no need to repeat the same case logic over and over again.
See if this gets...
March 21, 2008 at 9:28 am
Go back and re-read some of the previous posts, because the pieces are there for you to put together and I have a job too...
You're not doing anything to "unpivot"...
March 21, 2008 at 9:10 am
If you're in the business of making IDs, then just make some IDs...
Select ConsultantID, 2 as ActivityID, PersonalSales, Date
From Table
union all
Select ConsultantID, 3 ,FirstLevelSales, Date
From Table
Union all
Select ConsultantID, 4,...
March 21, 2008 at 8:54 am
Oh, I see. In your original post, you show those values as columns in a table. What you are trying to do in one query is UNPIVOT the columns into...
March 21, 2008 at 8:27 am
So the question becomes...how do you know whether a sale is Personal, first, second or third? Once you know that, group by that column, and it should break it out...
March 21, 2008 at 8:20 am
...but now I need to join in my temp table #ActivitySummary...
I suppose this should be painfully obvious, but you need to relate the ActivitySort column to some other column in...
March 21, 2008 at 6:57 am
... only update those records whose year value is different from the current year according to server time.
Right now, it updates those that are different, and it only adds one....
March 20, 2008 at 2:05 pm
Well, your basic crosstab in SQL looks like:
use AdventureWorks
GO
Declare @MonthsOut int, @StartDate datetime, @EndDate datetime
Set @MonthsOut = 6
Set @StartDate = '2/1/2002'
Set @EndDate = dateadd(mm,@MonthsOut, @StartDate)
Select SalesPersonID,
Jan = sum(case when...
March 20, 2008 at 1:26 pm
Exploring the trigger route...
CREATE TABLE [dbo].[TestTable1](
[n] [int] IDENTITY(1,1) NOT NULL,
[BadDate] [datetime] NOT NULL,
CONSTRAINT [PK_TestTable1] PRIMARY KEY CLUSTERED
(
[n] ASC
)
go
create TRIGGER [dbo].[trg_Test1]
ON [dbo].[TestTable1]
for...
March 20, 2008 at 12:43 pm
You might have to go the dynamic route on this one:
Declare @sql nvarchar(1000)
Set @sql = 'Select EmpID as ' + @ID + ' ,EmpName as '...
March 17, 2008 at 7:23 am
Viewing 15 posts - 46 through 60 (of 153 total)