Click here to Skip to main content
15,920,603 members
Home / Discussions / Database
   

Database

 
Generaloverwite/add between two databases help Pin
Anonymous6-Jul-04 3:51
Anonymous6-Jul-04 3:51 
Questioncan anyone optimize this query Pin
xcavin6-Jul-04 3:15
xcavin6-Jul-04 3:15 
AnswerRe: can anyone optimize this query Pin
RichardGrimmer6-Jul-04 4:12
RichardGrimmer6-Jul-04 4:12 
AnswerRe: can anyone optimize this query Pin
Michael Potter6-Jul-04 7:28
Michael Potter6-Jul-04 7:28 
GeneralRe: can anyone optimize this query Pin
xcavin6-Jul-04 19:27
xcavin6-Jul-04 19:27 
GeneralRe: can anyone optimize this query Pin
xcavin6-Jul-04 20:03
xcavin6-Jul-04 20:03 
GeneralRe: can anyone optimize this query Pin
Michael Potter7-Jul-04 3:13
Michael Potter7-Jul-04 3:13 
AnswerRe: can anyone optimize this query Pin
michanne6-Jul-04 15:36
michanne6-Jul-04 15:36 
I am guessing "id" is really custid since you are looking for custid in it.

Are you looking for the max(priority) for EACH customer (1) or the max(priority) for all customers in pending(2)?

1.
Select *
From(
Select custid, max(priority)as Priority
From customer
Where status = 1
and custid <> ''
Group by id
) as subtable Join pending
On subtable.custid= pending.custid

2.
SELECT *
FROM Pending Join Customer
on pending.custid = customer.custid
WHERE priority = (
SELECT max(priority)
FROM customer Join pending
on customer.custid = pending.custid
WHERE customer.custid <> ''
and status = 1
)
Where pending.custid <> ''

michanne
GeneralSQL connection Pin
tennis045-Jul-04 20:07
tennis045-Jul-04 20:07 
GeneralRe: SQL connection Pin
Michael Potter6-Jul-04 7:37
Michael Potter6-Jul-04 7:37 
GeneralRe: SQL connection Pin
tennis047-Jul-04 19:53
tennis047-Jul-04 19:53 
GeneralRe: SQL connection Pin
Michael Potter8-Jul-04 3:07
Michael Potter8-Jul-04 3:07 
GeneralRe: SQL connection Pin
tennis048-Jul-04 15:10
tennis048-Jul-04 15:10 
GeneralRe: SQL connection Pin
Michael Potter9-Jul-04 3:36
Michael Potter9-Jul-04 3:36 
GeneralTable name a String Pin
si_695-Jul-04 0:21
si_695-Jul-04 0:21 
GeneralRe: Table name a String Pin
michanne15-Jul-04 5:50
michanne15-Jul-04 5:50 
GeneralRe: Table name a String Pin
Grimolfr6-Jul-04 9:38
Grimolfr6-Jul-04 9:38 
Generaltext to ntext Pin
ShankarPS4-Jul-04 17:04
ShankarPS4-Jul-04 17:04 
GeneralRe: text to ntext Pin
Hesham Amin4-Jul-04 22:44
Hesham Amin4-Jul-04 22:44 
GeneralRe: text to ntext Pin
Mike Dimmick7-Jul-04 5:56
Mike Dimmick7-Jul-04 5:56 
GeneralSQL Help. Pin
brdavid4-Jul-04 14:59
brdavid4-Jul-04 14:59 
GeneralRe: SQL Help. Pin
Hesham Amin4-Jul-04 22:50
Hesham Amin4-Jul-04 22:50 
GeneralRe: SQL Help. Pin
brdavid6-Jul-04 4:49
brdavid6-Jul-04 4:49 
GeneralRe: SQL Help. Pin
Grimolfr6-Jul-04 9:58
Grimolfr6-Jul-04 9:58 
GeneralRe: SQL Help. Pin
brdavid6-Jul-04 14:00
brdavid6-Jul-04 14:00 

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.