Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vision99
Starting Member
14 Posts |
Posted - 2009-05-26 : 11:25:42
|
| CREATE TABLE #temp1( id INT, )INSERT INTO #temp1 VALUES('11')INSERT INTO #temp1 VALUES('11')INSERT INTO #temp1 VALUES('12')INSERT INTO #temp1 VALUES('11')INSERT INTO #temp1 VALUES('11')INSERT INTO #temp1 VALUES('11')INSERT INTO #temp1 VALUES('55')INSERT INTO #temp1 VALUES('66')INSERT INTO #temp1 VALUES('66')INSERT INTO #temp1 VALUES('66')INSERT INTO #temp1 VALUES('66')INSERT INTO #temp1 VALUES('55')INSERT INTO #temp1 VALUES('55')Need a query to display output as below using above #temp1 table.NOTE : should not do changes the table structure.***************-Vision |
|
|
zubamark
Starting Member
23 Posts |
Posted - 2009-05-26 : 11:27:49
|
| select * from #temp1id-----------11111211111155666666665555(13 row(s) affected) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-26 : 12:12:45
|
| is this a homework question? |
 |
|
|
vision99
Starting Member
14 Posts |
Posted - 2009-05-26 : 12:45:15
|
quote: Originally posted by visakh16 is this a homework question?
No!!! This is Interview qus...-Vision |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-26 : 12:52:45
|
| [code]SELECT REPLICATE('*',Cnt)FROM(SELECT COUNT(*) AS CntFROM #TempGROUP BY idORDER BY Cnt)t[/code] |
 |
|
|
vision99
Starting Member
14 Posts |
Posted - 2009-05-26 : 13:11:03
|
quote: Originally posted by visakh16
SELECT REPLICATE('*',Cnt)FROM(SELECT COUNT(*) AS CntFROM #TempGROUP BY idORDER BY Cnt)t
Hi I tested the query, showing err msg like: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. so removed the ORDER BY Clause and executed but displaying output like *************-Vision |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-26 : 13:15:19
|
| [code]SELECT REPLICATE('*',Cnt)FROM(SELECT COUNT(*) AS CntFROM #TempGROUP BY id)tORDER BY Cnt[/code] |
 |
|
|
|
|
|