Click here to Skip to main content
15,669,905 members
Home / Discussions / Database
   

Database

 
GeneralRe: RANKING IN VB.NET MYSQL Pin
KipkoechE11-Feb-15 1:32
KipkoechE11-Feb-15 1:32 
GeneralRe: RANKING IN VB.NET MYSQL Pin
Richard MacCutchan11-Feb-15 1:36
mveRichard MacCutchan11-Feb-15 1:36 
GeneralRe: RANKING IN VB.NET MYSQL Pin
KipkoechE11-Feb-15 1:41
KipkoechE11-Feb-15 1:41 
AnswerRe: RANKING IN VB.NET MYSQL Pin
GuyThiebaut11-Feb-15 2:11
professionalGuyThiebaut11-Feb-15 2:11 
GeneralRe: RANKING IN VB.NET MYSQL Pin
KipkoechE11-Feb-15 2:23
KipkoechE11-Feb-15 2:23 
GeneralRe: RANKING IN VB.NET MYSQL Pin
GuyThiebaut11-Feb-15 2:28
professionalGuyThiebaut11-Feb-15 2:28 
QuestionVB.NET ITEXTSHARP PDF REPORTS Pin
KipkoechE10-Feb-15 6:38
KipkoechE10-Feb-15 6:38 
QuestionMySQL for MFC application Pin
Anu_Bala10-Feb-15 0:14
Anu_Bala10-Feb-15 0:14 
AnswerRe: MySQL for MFC application Pin
Kornfeld Eliyahu Peter10-Feb-15 2:37
professionalKornfeld Eliyahu Peter10-Feb-15 2:37 
Questionvb.net with mysql Pin
KipkoechE8-Feb-15 17:04
KipkoechE8-Feb-15 17:04 
AnswerRe: vb.net with mysql Pin
PIEBALDconsult8-Feb-15 17:33
professionalPIEBALDconsult8-Feb-15 17:33 
GeneralRe: vb.net with mysql Pin
KipkoechE8-Feb-15 18:56
KipkoechE8-Feb-15 18:56 
GeneralRe: vb.net with mysql Pin
PIEBALDconsult9-Feb-15 3:47
professionalPIEBALDconsult9-Feb-15 3:47 
AnswerRe: vb.net with mysql Pin
ZurdoDev9-Feb-15 4:01
professionalZurdoDev9-Feb-15 4:01 
GeneralRe: vb.net with mysql Pin
Jörgen Andersson9-Feb-15 4:09
professionalJörgen Andersson9-Feb-15 4:09 
QuestionRe: vb.net with mysql Pin
Eddy Vluggen9-Feb-15 5:53
professionalEddy Vluggen9-Feb-15 5:53 
QuestionPopulate one table from another Pin
Corporal Agarn6-Feb-15 4:50
professionalCorporal Agarn6-Feb-15 4:50 
QuestionRe: Populate one table from another Pin
Wendelius6-Feb-15 5:23
mentorWendelius6-Feb-15 5:23 
AnswerRe: Populate one table from another Pin
Corporal Agarn6-Feb-15 6:49
professionalCorporal Agarn6-Feb-15 6:49 
AnswerRe: Populate one table from another Pin
Jörgen Andersson9-Feb-15 21:29
professionalJörgen Andersson9-Feb-15 21:29 
Tough one, it took me a while to understand what you wanted, and I still may have misunderstood the purpose.
Anyway, here's a try, tell me if I'm off the target.

Since there is no UnGroup or UnCount function in SQL we have to create that ourselves.
One way is to use an auxiliary Sequence. Here's a fairly fast way to create a sequence:
SQL
CREATE TABLE numbersequence (Number  int  not null);
INSERT INTO numbersequence(Number)
SELECT  TOP 100 row_number() over(order by t1.number) as N
FROM    master..spt_values t1 
CROSS JOIN master..spt_values t2
;
Adjust for the size you need.
Now we can "Uncount" the table and create a rownumber to join on:
SQL
select  testid
       ,ROW_NUMBER() OVER(order by testid) AS rn
from    MyTestCounts tc,numbersequence n
where   tc.cnt >= n.number
The whole query to connect unrelated IDX to TestID would look like this:
SQL
with counts as (
    select  testid
           ,ROW_NUMBER() OVER(order by testid) AS rn
    from    MyTestCounts tc,numbersequence n
    where   tc.cnt >= n.number
    )
,tqb as (
    SELECT  TOP (select sum(cnt) from MyTestCounts) TQB.IDX
           ,ROW_NUMBER() OVER(order by testid) AS rn
    FROM    MyTestBase TQB
    WHERE   TestID IS NULL
    ORDER BY NEWID()
    )
select  IDX,TestID
from    counts c
join    tqb t
    on  c.rn = t.rn

Here's[^] the fiddle.
Wrong is evil and must be defeated. - Jeff Ello

GeneralRe: Populate one table from another Pin
Corporal Agarn10-Feb-15 0:42
professionalCorporal Agarn10-Feb-15 0:42 
GeneralRe: Populate one table from another Pin
Corporal Agarn10-Feb-15 2:23
professionalCorporal Agarn10-Feb-15 2:23 
GeneralRe: Populate one table from another Pin
Jörgen Andersson10-Feb-15 4:23
professionalJörgen Andersson10-Feb-15 4:23 
AnswerRe: Populate one table from another Pin
Rony8910-Feb-15 17:00
Rony8910-Feb-15 17:00 
GeneralRe: Populate one table from another Pin
Corporal Agarn11-Feb-15 0:43
professionalCorporal Agarn11-Feb-15 0:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.