Форум Торонто - Torontovka.com
[Search] [Rules] [Register] [Login]
Forums » Archive » SQL query 
Page: 1 [2] All
Author Message
Joined: 11/16/2002
Posts: 9
Posted on Monday, December 20, 2004 2:31:00 PM
 

Nu ideja v tom chto ti joinish tablicy samy k sebe, i schitaesh dlja kajdoj stroki kol-vo zapisej u kotorix TotalSent bol'she chem u tekushej stroki,

nu a potom - gruppirovka / sortirovka
Joined: 8/24/2004
Posts: 6087
Posted on Monday, December 20, 2004 2:32:00 PM
 
А, у тебя все в одной таблице, и DomainName и TotalSent уже суммировать не надо... Тогда еще проще, конечно.

--
KOHb a.k.a. AVL
Joined: 3/5/2002
Posts: 19784
Posted on Monday, December 20, 2004 2:32:00 PM
 
Hint,
Твой запрос вернёт пустой сет.

Конь,
Я хочу без курсора. :)


--
LONG LIVE ROCK-N-ROLL!
Joined: 8/24/2004
Posts: 6087
Posted on Monday, December 20, 2004 2:34:00 PM
 
Hint правильно написал, только надо убрать вот это лишнее условие: mt1.Domain=mt2.Domain.

--
KOHb a.k.a. AVL
Joined: 3/5/2002
Posts: 19784
Posted on Monday, December 20, 2004 2:37:00 PM
 
ладно, всем спа. попробую ваши способы.
хотя уже нашёл свой. :))

--
LONG LIVE ROCK-N-ROLL!
Joined: 6/21/2001
Posts: 10125
Posted on Monday, December 20, 2004 3:29:00 PM
 
в mysql есть limit. можно order by а потом limit 20

Edited by - Pasha on 12/20/2004 3:35:34 PM
Joined: 8/24/2004
Posts: 6087
Posted on Monday, December 20, 2004 4:29:00 PM
 
Pasha, не получится.

--
KOHb a.k.a. AVL
Joined: 3/18/2004
Posts: 230
Posted on Monday, December 20, 2004 6:09:00 PM
 


SELECT *
FROM MessageTable as t1

WHERE t1.TotalSent ]=
(SELECT MIN(TotalSent)
FROM
(SELECT TOP 2 * from MessageTable
WHERE MessageID =t1.MessageID
ORDER BY TotalSent DESC
) TMAX
)

Tested - working
Joined: 1/26/2007
Posts: 3
Posted on Wednesday, May 2, 2007 7:55:44 AM
 
http://a2e7eeb6ab050975ccea90e2b3e75696-t.ghoiou0.info <a href="http://a2e7eeb6ab050975ccea90e2b3e75696-h.ghoiou0.info">a2e7eeb6ab050975ccea90e2b3e75696</a> http://a2e7eeb6ab050975ccea90e2b3e75696-b1.ghoiou0.info a2e7eeb6ab050975ccea90e2b3e75696 http://a2e7eeb6ab050975ccea90e2b3e75696-b3.ghoiou0.info 196c3da0ce3e9a23267e7eab02ad2b11
Page: 1 [2] All
Forums » Archive » SQL query 
Copyright © 2020 Torontovka.com, All rights reserved