Click here to Skip to main content
15,896,118 members
Home / Discussions / Database
   

Database

 
GeneralSQL Query Pin
Ali Rashid31-Mar-08 23:45
Ali Rashid31-Mar-08 23:45 
GeneralRe: SQL Query Pin
Blue_Boy1-Apr-08 3:28
Blue_Boy1-Apr-08 3:28 
GeneralRe: SQL Query Pin
Ali Rashid1-Apr-08 6:01
Ali Rashid1-Apr-08 6:01 
GeneralRe: SQL Query Pin
Ali Rashid1-Apr-08 6:07
Ali Rashid1-Apr-08 6:07 
GeneralRe: SQL Query Pin
Blue_Boy1-Apr-08 9:17
Blue_Boy1-Apr-08 9:17 
GeneralRe: SQL Query Pin
Ali Rashid1-Apr-08 22:05
Ali Rashid1-Apr-08 22:05 
GeneralRe: SQL Query Pin
Blue_Boy2-Apr-08 7:43
Blue_Boy2-Apr-08 7:43 
GeneralRe: SQL Query [modified] Pin
Syed Mehroz Alam2-Apr-08 9:30
Syed Mehroz Alam2-Apr-08 9:30 
Since we are sure that our Min/Max prices will be unique so we can write a subquery for retrieving the IDs, here's an addition to my original query.

Select MinUniquePrice, ( Select Top(1) ID from #MyTable T where T.ItemPrice=MinUniquePrice ) as MinPriceID,
	MaxUniquePrice, ( Select Top(1) ID from #MyTable T where T.ItemPrice=MaxUniquePrice ) as MaxPriceID
From
(
	Select min(ItemPrice) as MinUniquePrice, max(ItemPrice) as MaxUniquePrice
	 From
		( select ItemPrice, Count(*) as ItemPriceCount 
			from #Mytable 
			group by ItemPrice 
			Having Count(*) = 1 
		) as MyTableWithUniqueItemPrices
) As MyTableWithMinMaxItemPrices


But Blue_boy's approach was better. I really liked it. Big Grin | :-D

Regards,
Mehroz


modified on Wednesday, April 2, 2008 3:55 PM

GeneralRe: SQL Query Pin
Blue_Boy3-Apr-08 12:14
Blue_Boy3-Apr-08 12:14 
AnswerRe: SQL Query Pin
mushfiqcs2-Apr-08 1:10
mushfiqcs2-Apr-08 1:10 
GeneralRe: SQL Query Pin
mushfiqcs2-Apr-08 1:10
mushfiqcs2-Apr-08 1:10 
QuestionRAM usage Pin
Dobromir Dimitrov31-Mar-08 21:55
Dobromir Dimitrov31-Mar-08 21:55 
GeneralRe: RAM usage Pin
GuyThiebaut31-Mar-08 23:56
professionalGuyThiebaut31-Mar-08 23:56 
GeneralRe: RAM usage Pin
Ali Rashid1-Apr-08 23:28
Ali Rashid1-Apr-08 23:28 
GeneralRe: RAM usage Pin
SimulationofSai2-Apr-08 1:23
SimulationofSai2-Apr-08 1:23 
GeneralMS Acess SQL Query using VS Query Builder and Variable Field Names Pin
Christian Yeates31-Mar-08 21:33
Christian Yeates31-Mar-08 21:33 
Questionhow to save only time in database field Pin
findtango31-Mar-08 19:10
findtango31-Mar-08 19:10 
GeneralRe: how to save only time in database field Pin
pmarfleet31-Mar-08 19:45
pmarfleet31-Mar-08 19:45 
GeneralRe: how to save only time in database field Pin
Ali Rashid31-Mar-08 23:52
Ali Rashid31-Mar-08 23:52 
QuestionCombobox's selected column must fill the Gridview Pin
Tristania Dementium31-Mar-08 2:38
Tristania Dementium31-Mar-08 2:38 
Generalselect and group by problem Pin
Xmen Real 31-Mar-08 1:13
professional Xmen Real 31-Mar-08 1:13 
GeneralRe: select and group by problem Pin
Rob Philpott31-Mar-08 1:20
Rob Philpott31-Mar-08 1:20 
GeneralRe: select and group by problem Pin
Xmen Real 31-Mar-08 1:22
professional Xmen Real 31-Mar-08 1:22 
GeneralRe: select and group by problem Pin
Rob Philpott31-Mar-08 1:26
Rob Philpott31-Mar-08 1:26 
GeneralRe: select and group by problem Pin
Xmen Real 31-Mar-08 1:30
professional Xmen Real 31-Mar-08 1:30 

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.