January 10, 2010 at 11:18 am
ifila (1/10/2010)
SELECT COUNT(DISTINCT(variablename))Let's assume i have 1000 variable names, with duplicates, which is why i need DISTINCT.
I only want to display the TOP 50.
SELECT TOP 50 COUNT(DISTINCT(variablename)) does not work.
SET ROWCOUNT 50 does not work.
What would be the correct syntax of the above statement?
Vague requirements. No sample data, no expected results. Again, where do we start?
January 10, 2010 at 11:32 am
Lynn,
You need to chill!
I can see that my lack of compliance is irritating you. I will just ask my Indian developers tomorrow.
Problem solved 🙂
January 10, 2010 at 11:49 am
ifila (1/10/2010)
Lynn,You need to chill!
I can see that my lack of compliance is irritating you. I will just ask my Indian developers tomorrow.
Problem solved 🙂
I'm sorry, but why should I chill? You haven't explained your problem well enough and you expect an answer? You need to chill.
I'd be more than willing to help if I knew where to start.
January 10, 2010 at 12:32 pm
Since you're not even willing (it appears) to answer my very simple questions, I'm quite happy to leave this to your highly qualified indian developers. I have better things to do than play 'Twenty Questions' on a Sunday evening.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 10, 2010 at 12:36 pm
Obscure help for an unclear question. Try this hints game:
from BOL on the TOP clause:
Specifies that only the first set of rows will be returned from the query result. The set of rows can be either a number or a percent of the rows. The TOP expression can be used in SELECT, INSERT, UPDATE, MERGE, and DELETE statements.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 10, 2010 at 12:50 pm
Troubled I am by your lack of discussion. Two-way street discussions are. Question you asked, but information unwilling you are to give.
Not knowing what it is you are trying to accomplish, here is a shot in the dark.
create table dbo.TestData (
ID int identity(1,1),
TestName varchar(32),
TestInfo uniqueidentifier
);
insert into dbo.TestData (
TestName,
TestInfo
)
select 'Able', NEWID() union all
select 'Baker', NEWID() union all
select 'Charlie', NEWID() union all
select 'Able', NEWID() union all
select 'Delta', NEWID() union all
select 'Echo', NEWID() union all
select 'Baker', NEWID() union all
select 'Able', NEWID() union all
select 'Foxtrot', NEWID() union all
select 'Charlie', NEWID() union all
select 'Hotel', NEWID() union all
select 'Foxtrot', NEWID() union all
select 'Tango', NEWID() union all
select 'Yankee', NEWID() union all
select 'Echo', NEWID() union all
select 'Hotel', NEWID();
select
ID,
TestName,
TestInfo
from
dbo.TestData
;
select COUNT(distinct TestName) from dbo.TestData;
-- select all records for the first 3 unique names in TestName
with UniqueNames (
TestName
) as (
select top (3)
TestName
from
dbo.TestData
group by
TestName
order by
TestName
)
select
td.ID,
td.TestName,
td.TestInfo
from
dbo.TestData td
inner join UniqueNames un
on (td.TestName = un.TestName);
drop table dbo.TestData;
So, how far off target am I? Are you willing to provide us with more information than the vague discriptions you have provided so far? If not, please take your complaints elsewhere. We are willing to help you if you are willing to help yourself.
EDIT: Changed it from 5 to 3.
January 10, 2010 at 12:54 pm
......Help you i will, oh Jedi master.
The force is strong in this one!
January 10, 2010 at 12:55 pm
See also http://www.sqlservercentral.com/Forums/FindPost844653.aspx
See also http://forums.asp.net/t/1447537.aspx :w00t:
See also http://sjc.ironspeed.com/post?id=3575239&goto=nextnewest
The earliest of these posts is six months ago.
Surely it's worth spending fifteen minutes setting up a little sample data and providing us with a sensible, logical and rational explanation of the problem?
Edited: per Lynn's request.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 10, 2010 at 12:55 pm
Posted a response - but the tone of the thread has changed.
So how far off is Lynn's solution?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 10, 2010 at 1:03 pm
ifila (1/10/2010)
......Help you i will, oh Jedi master.The force is strong in this one!
Sacrasm, good. Now try answering the question instead.
January 10, 2010 at 1:06 pm
lobbymuncher (1/10/2010)
See also http://www.sqlservercentral.com/Forums/FindPost844653.aspxSee also http://forums.asp.net/t/1447537.aspx :w00t:
See also http://sjc.ironspeed.com/post?id=3575239&goto=nextnewest
The earliest of these posts is six months ago.
Surely it's worth spending fifteen minutes setting up a little sample data and providing us with a sensible, logical and rational explanation of the problem?
Do you think you could edit your post and put the [ url ] [ /url ] (no spaces inside the brackets) around the url's? This would allow those of us who would like to see them to just click on them instead of having to cut and paste in our browsers.
Thanks.
January 10, 2010 at 1:07 pm
Lynn Pettis (1/10/2010)
ifila (1/10/2010)
......Help you i will, oh Jedi master.The force is strong in this one!
...
I am waiting for the response on this one first. I saw his post in reply to your answer right after I posted my last post. I figured I would go back and withhold that post expecting that he would reply with some info.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 10, 2010 at 1:31 pm
Lynn Pettis (1/10/2010)
Do you think you could edit your post and put the [ url ] [ /url ] (no spaces inside the brackets) around the url's? This would allow those of us who would like to see them to just click on them instead of having to cut and paste in our browsers.Thanks.
Sure Lynn, original is edited.
Cheers
ChrisM@home
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 10, 2010 at 1:36 pm
lobbymuncher (1/10/2010)
Lynn Pettis (1/10/2010)
Do you think you could edit your post and put the [ url ] [ /url ] (no spaces inside the brackets) around the url's? This would allow those of us who would like to see them to just click on them instead of having to cut and paste in our browsers.Thanks.
Sure Lynn, original is edited.
Cheers
ChrisM@home
Ahhh, better. Thanks Chris.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 10, 2010 at 1:58 pm
lobbymuncher (1/10/2010)
Lynn Pettis (1/10/2010)
Do you think you could edit your post and put the [ url ] [ /url ] (no spaces inside the brackets) around the url's? This would allow those of us who would like to see them to just click on them instead of having to cut and paste in our browsers.Thanks.
Sure Lynn, original is edited.
Cheers
ChrisM@home
Yes, thank you Chris.
Now, is it just me or do all of these posts seem to revolve around the same code or process as in this thread??
Viewing 15 posts - 16 through 30 (of 103 total)
You must be logged in to reply to this topic. Login to reply