Hi,
I am wondering is it worthwhile to index a column in a table with 500 million rows if the column on only has 5 distinct values (and nulls) in it?
The column is a varchar(255), but the longest value is about 10 chars long.
Thanks
Hi,
This is what I am doing. Basically I want all inserts and deletes to run, or not at all.
CREATE PROC myProc
AS
BEGIN
BEGIN TRAN
BEGIN TRY
insert to table x...
insert to table y...
insert to table z...
delete table a...
END TRY
BEGIN CATCH
do something...
END CATCH
IF @@TRANCOUNT >...
SET DATEFIRST 1
declare @wk int set @wk = 1
declare @yr int set @yr = 2007
select dateadd (week, @wk, dateadd (year, @yr-1900, 0)) - 4 -
datepart(dw, dateadd (week, @wk, dateadd (year, @yr-1900, 0)) - 4) + 1
-- was enough for me to figure out what I need, thanks!!!
Hi George,
No, what I want is to sum up some data by week, so I'm selecting the week number then grouping on it.
It works fine, but I also want to see what the actual DATE is for the given week number.
So in my report it will look like:
week_no date count
1 1/3/11 99
2...
I'm sorry that won't work because I don't want to group on created_dt, only week_no and the week day for that week_no
as in
1 Jan 3, 2011
2 Jan 10, 2011
3 Jan 17, 2011
etc
Hi,
I've been searching all over the internet but not coming up with a satisfactory answer.
Basically, I have this query:
select datepart(week, created_dt) as week_no from myTable
which gives me: 1, 2, 3, etc for "week_no"
but since this is for a report, I also want the ACTUAL date the...
Yes, this works, thanks.
Unfortunately, I didn't really explain clearly what I wanted, sorry:
REPORT:
abc 2010-12-01 NULL NULL 2010-12-04 NULL
def 2010-12-01 NULL NULL NULL NULL
xyz NULL 2010-12-02 NULL NULL 2010-12-05
I need a column for each DAY...
Hi,
I am not too familiar with the pivot expression and I can't seem to find any examples online.
What I'm trying to do shouldn't be hard, just don't know the syntax. I am trying to achieve the output under "REPORT".
RAW DATA:
name date
abc 2010-12-01
abc 2010-12-04
def...
Correction, the query should be:
select id, sku
from myTable
into #temp
where sku = 'abc'
or sku = 'def'
or sku = 'ghi'
or sku in ('yy', 'zz')
group by id, sku
order by id, sku
Hi,
I have a query that I know is probably easy to write, but I'm just missing it for some reason.
Here's the basic query:
select id, sku from myTable
into #temp
where sku = 'abc'
or sku = 'def'
or sku = 'ghi'
or sku in ('yy', 'zz')
group by profile_id, sku
order by profile_id, sku
Basically...
Hi,
I have a table with a column that can hold single values as well as a comma-delimited string, for exampe:
column
Joe, 1, Red
Mary
Ned, 2, Blue, Purple
Susan, 3
etc
How can I write something to grab a distinct result set of all the various values, which would be:
Joe
Mary
Ned
Susan
1
2
3...
Hi,
My data set looks like:
id type date count
1 dogs 2010-01-01 1
1 dogs 2010-01-15 4
1 dogs 2010-01-31 10
1 cats 2010-02-02 4
1 cats 2010-02-16 7
What I want to do is write a query that will return the record that contains the max(date) for a given...
Hi,
Nevermind, I figured it out. Turns out if I put the results for both tables in a temp table first, it is a relatively easy matter to get what I want by the use of a correlated subquery using min.
I guess I got myself confused by overcomplicating the issue, and not taking a sufficient break...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.