Click here to Skip to main content
15,887,404 members
Home / Discussions / Database
   

Database

 
Questionquery error Pin
Bhairava Prasad30-May-13 2:03
Bhairava Prasad30-May-13 2:03 
AnswerRe: query error Pin
Anurag Sinha V30-May-13 2:25
Anurag Sinha V30-May-13 2:25 
AnswerRe: query error Pin
Mycroft Holmes30-May-13 12:03
professionalMycroft Holmes30-May-13 12:03 
AnswerRe: query error Pin
Azarudhin4-Jun-13 3:41
professionalAzarudhin4-Jun-13 3:41 
QuestionMultiple Join to the same field Pin
Jassim Rahma29-May-13 4:31
Jassim Rahma29-May-13 4:31 
AnswerRe: Multiple Join to the same field Pin
David Mujica29-May-13 4:56
David Mujica29-May-13 4:56 
AnswerRe: Multiple Join to the same field Pin
Mycroft Holmes29-May-13 12:49
professionalMycroft Holmes29-May-13 12:49 
QuestionSelect top 2 not working on Maximum Record using SQL Pin
SE Ubaid29-May-13 2:38
SE Ubaid29-May-13 2:38 
Issue occrue on select top 2 like this
when run the following query then show the following result

SELECT u.ElectionDtlID,u.PartyShortNameEng,u.ConstituencyName,u.VotesObtained
FROM tblElectionsDetail u where u.ConstituencyName='NA 108' and u.electionyear='2013'
and u.VotesObtained > 0

RESULT:
ID NameEng Constituency VotesObtained
10864 PPPP NA 108 29883
10865 PMLN NA 108 73789
10866 PTI NA 108 25406
10867 JI NA 108 18270
10868 Ind NA 108 85009

But now i want to get only top result of Maximum VotesObtained Candidate
like this :
Query:

select top 2 VotesObtained from tblElectionsDetail where ConstituencyName='NA 108';
and electionyear='2013'; order by VotesObtained desc

Then this issue the following Result
OutPut Table:
VotesObtained
85009
73789

this is working good and also result show correct but when i want to show max/top 2 recrod but order by asc then it's working correct like this

Query:

select top 2 VotesObtained from tblElectionsDetail where ConstituencyName='na 108'
and electionyear='2013' order by VotesObtained asc

the result of the query like this
OutPut Table:
VotesObtained
0
0

so i wan to get the result like this.

VotesObtained
73789
85009

any body can help me ?

-- modified 29-May-13 8:47am.
AnswerRe: Select top 2 not working on Maximum Record using SQL Pin
Eddy Vluggen29-May-13 3:17
professionalEddy Vluggen29-May-13 3:17 
AnswerRe: Select top 2 not working on Maximum Record using SQL Pin
Arman S.29-May-13 9:44
Arman S.29-May-13 9:44 
Questiondecryption Pin
Member 870181328-May-13 6:42
Member 870181328-May-13 6:42 
AnswerRe: decryption Pin
R. Giskard Reventlov28-May-13 7:43
R. Giskard Reventlov28-May-13 7:43 
QuestionRe: decryption Pin
Eddy Vluggen28-May-13 9:45
professionalEddy Vluggen28-May-13 9:45 
AnswerRe: decryption Pin
Member 870181330-May-13 16:37
Member 870181330-May-13 16:37 
GeneralRe: decryption Pin
Eddy Vluggen31-May-13 6:23
professionalEddy Vluggen31-May-13 6:23 
AnswerRe: decryption Pin
poongunrans28-May-13 20:21
poongunrans28-May-13 20:21 
QuestionSQL Pin
Shiv irfi26-May-13 21:11
Shiv irfi26-May-13 21:11 
AnswerRe: SQL Pin
Mycroft Holmes26-May-13 21:52
professionalMycroft Holmes26-May-13 21:52 
JokeRe: SQL Pin
Killzone DeathMan28-May-13 5:35
Killzone DeathMan28-May-13 5:35 
AnswerRe: SQL Pin
Eddy Vluggen28-May-13 9:59
professionalEddy Vluggen28-May-13 9:59 
AnswerRe: SQL Pin
Azarudhin4-Jun-13 3:45
professionalAzarudhin4-Jun-13 3:45 
AnswerRe: SQL Pin
prakash.chakrala5-Jul-13 1:09
prakash.chakrala5-Jul-13 1:09 
QuestionSelect first entries in a table matching given criteria Pin
Dewald26-May-13 10:12
Dewald26-May-13 10:12 
AnswerRe: Select first entries in a table matching given criteria Pin
Mycroft Holmes26-May-13 12:47
professionalMycroft Holmes26-May-13 12:47 
GeneralRe: Select first entries in a table matching given criteria Pin
Dewald26-May-13 22:10
Dewald26-May-13 22:10 

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.