Click here to Skip to main content
15,890,185 members
Home / Discussions / Database
   

Database

 
QuestionMembership Stored Procedures Confusion Pin
Brendan Vogt11-Mar-08 22:59
Brendan Vogt11-Mar-08 22:59 
GeneralRe: Membership Stored Procedures Confusion Pin
Mark J. Miller13-Mar-08 5:48
Mark J. Miller13-Mar-08 5:48 
QuestionRunning SQL Server stored procedure Pin
ambrose11-Mar-08 22:56
ambrose11-Mar-08 22:56 
GeneralRe: Running SQL Server stored procedure Pin
Mark J. Miller13-Mar-08 5:56
Mark J. Miller13-Mar-08 5:56 
GeneralConcurrency violation Pin
baranils11-Mar-08 21:31
baranils11-Mar-08 21:31 
GeneralRe: Concurrency violation Pin
Mark J. Miller13-Mar-08 6:01
Mark J. Miller13-Mar-08 6:01 
GeneralRe: Concurrency violation Pin
baranils13-Mar-08 6:54
baranils13-Mar-08 6:54 
Generalsql structure Pin
Tara1411-Mar-08 21:02
Tara1411-Mar-08 21:02 
Hi,

I have two table like this:

quote_tb:

ID   item  vendor  quote
11     a     v1    100
11     a     v2	   200
11     b     v1    400
11     b     v2    300
11     c     v1    555
11     c     v2    777
22     a     v1    122
22     a     v2	   222
22     b     v1    322
22     b     v2    422
22     c     v1    555
22     c     v2    777

vendor_tb

name  phone#   fax#    address#
v1     1111    2222    3, x street
v2     1212    2323    4, m street


I am trying to write an sql that given me the following result:
lowestQ_tb
ID   item  vendor  quote  phone#    fax#
11     a    v1       100   1111      2222
11     b    v2       300   1212      2323
11     c    v1       555   1111      2222


i.e for each of the items a,b,c having the id(11) select the vendors that have the lease quote and then get the phone and fax numbers of the vendors form the table vendor_tb.

To get the first part i.e. lowest quote for each item, this is the sql I use:

SELECT f.item, f.vendor, f.quote 
	FROM (SELECT item, min(quote) AS minprice FROM quote_tb WHERE ID='11' GROUP BY item) 
	AS x INNER JOIN quote_tb AS f ON f.item = x.item AND f.quote = x.minprice

which gives me the result:

ID   item  vendor  quote
11     a    v1       100
11     b    v2       300
11     c    v1       555

I don't know how to take it further form here to get lowestQ_tb. Please can you tell me how to get the above desired result i.e tabele lowestQ_tb. Is it possible to do such a thing?

Thanks,
Tara

GeneralRe: sql structure Pin
andyharman12-Mar-08 0:08
professionalandyharman12-Mar-08 0:08 
GeneralRe: sql structure Pin
Tara1412-Mar-08 7:45
Tara1412-Mar-08 7:45 
GeneralRe: sql structure Pin
Syed Mehroz Alam12-Mar-08 0:17
Syed Mehroz Alam12-Mar-08 0:17 
GeneralRe: sql structure Pin
Tara1412-Mar-08 5:50
Tara1412-Mar-08 5:50 
GeneralRe: sql structure Pin
Tara1412-Mar-08 7:36
Tara1412-Mar-08 7:36 
GeneralPassword Expiry Pin
manowj11-Mar-08 20:24
manowj11-Mar-08 20:24 
GeneralCannot resolve collation conflict for equal to operation. Pin
AlexeiXX311-Mar-08 14:44
AlexeiXX311-Mar-08 14:44 
GeneralRe: Cannot resolve collation conflict for equal to operation. Pin
AlexeiXX311-Mar-08 15:17
AlexeiXX311-Mar-08 15:17 
QuestionProblems Exporting From DataSet to .DBF File Pin
Snaider11-Mar-08 9:00
Snaider11-Mar-08 9:00 
GeneralRe: Problems Exporting From DataSet to .DBF File Pin
perryf_0011-Mar-08 12:12
perryf_0011-Mar-08 12:12 
GeneralRe: Problems Exporting From DataSet to .DBF File Pin
Snaider12-Mar-08 0:18
Snaider12-Mar-08 0:18 
GeneralDataRelation and NOCHECK add constraint Pin
CJacobus11-Mar-08 6:21
CJacobus11-Mar-08 6:21 
GeneralRe: DataRelation and NOCHECK add constraint Pin
Mark J. Miller11-Mar-08 7:28
Mark J. Miller11-Mar-08 7:28 
GeneralRe: DataRelation and NOCHECK add constraint Pin
CJacobus12-Mar-08 11:15
CJacobus12-Mar-08 11:15 
GeneralRe: DataRelation and NOCHECK add constraint Pin
Mark J. Miller13-Mar-08 3:29
Mark J. Miller13-Mar-08 3:29 
QuestionHow can i improve the performance of this query? Pin
tonyong11-Mar-08 4:24
tonyong11-Mar-08 4:24 
AnswerRe: How can i improve the performance of this query? Pin
Scott Dorman11-Mar-08 4:42
professionalScott Dorman11-Mar-08 4:42 

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.