Click here to Skip to main content
16,006,013 members
Home / Discussions / Database
   

Database

 
Questionsql table index (SQL2005) Pin
Sk8tzz17-Apr-06 23:43
Sk8tzz17-Apr-06 23:43 
AnswerRe: sql table index (SQL2005) Pin
Colin Angus Mackay17-Apr-06 23:59
Colin Angus Mackay17-Apr-06 23:59 
GeneralRe: sql table index (SQL2005) Pin
Sk8tzz18-Apr-06 0:03
Sk8tzz18-Apr-06 0:03 
AnswerRe: sql table index (SQL2005) Pin
Eric Dahlvang19-Apr-06 3:59
Eric Dahlvang19-Apr-06 3:59 
AnswerRe: sql table index (SQL2005) Pin
Eric Dahlvang19-Apr-06 4:01
Eric Dahlvang19-Apr-06 4:01 
GeneralRe: sql table index (SQL2005) Pin
Sk8tzz19-Apr-06 18:59
Sk8tzz19-Apr-06 18:59 
Questionintegrating 2 sql results Pin
dansoft17-Apr-06 18:21
dansoft17-Apr-06 18:21 
AnswerRe: integrating 2 sql results Pin
Colin Angus Mackay17-Apr-06 20:50
Colin Angus Mackay17-Apr-06 20:50 
You can put them in subqueries and join the result set of the subqueries together. Like this:

SELECT supplier.sname, failures.count, supplier.count
FROM
(
    select suppliers.sname, count(*) AS count 
    from failures,devices,suppliers 
    where devices.suppid=suppliers.suppid 
    and failures.deviceid=devices.deviceid 
    group by suppliers.sname
) AS supplier
INNER JOIN
(
    select suppliers.sname, count(*) AS count 
    from devices,suppliers 
    where devices.suppid=suppliers.suppid 
    group by suppliers.sname
) AS failure ON supplier.sname = failure.sname

The above query can be could be optimised further, but I wanted to show as much of your original SQL as possible so you can see how it fits together. It also assumes that sname is unique.

Does this help?


"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)

My: Website | Blog
GeneralRe: integrating 2 sql results Pin
dansoft18-Apr-06 4:30
dansoft18-Apr-06 4:30 
GeneralRe: integrating 2 sql results Pin
Darpan Gogia18-Apr-06 23:24
Darpan Gogia18-Apr-06 23:24 
GeneralRe: integrating 2 sql results Pin
dansoft19-Apr-06 2:40
dansoft19-Apr-06 2:40 
GeneralRe: integrating 2 sql results Pin
Darpan Gogia19-Apr-06 2:42
Darpan Gogia19-Apr-06 2:42 
GeneralRe: integrating 2 sql results Pin
dansoft19-Apr-06 2:55
dansoft19-Apr-06 2:55 
GeneralRe: integrating 2 sql results Pin
Darpan Gogia19-Apr-06 3:00
Darpan Gogia19-Apr-06 3:00 
GeneralRe: integrating 2 sql results Pin
dansoft19-Apr-06 3:11
dansoft19-Apr-06 3:11 
QuestionRe: integrating 2 sql results Pin
dansoft19-Apr-06 3:40
dansoft19-Apr-06 3:40 
AnswerRe: integrating 2 sql results Pin
Darpan Gogia19-Apr-06 3:56
Darpan Gogia19-Apr-06 3:56 
GeneralRe: integrating 2 sql results Pin
dansoft19-Apr-06 4:19
dansoft19-Apr-06 4:19 
GeneralRe: integrating 2 sql results Pin
dansoft19-Apr-06 6:03
dansoft19-Apr-06 6:03 
QuestionSql 2000 'text' datatype Pin
karinb17-Apr-06 9:52
karinb17-Apr-06 9:52 
AnswerRe: Sql 2000 'text' datatype Pin
Eric Dahlvang17-Apr-06 10:18
Eric Dahlvang17-Apr-06 10:18 
QuestionRe: Sql 2000 'text' datatype Pin
Eric Dahlvang17-Apr-06 10:21
Eric Dahlvang17-Apr-06 10:21 
AnswerRe: Sql 2000 'text' datatype Pin
karinb17-Apr-06 10:29
karinb17-Apr-06 10:29 
AnswerRe: Sql 2000 'text' datatype Pin
Eric Dahlvang17-Apr-06 10:58
Eric Dahlvang17-Apr-06 10:58 
GeneralRe: Sql 2000 'text' datatype Pin
karinb17-Apr-06 11:50
karinb17-Apr-06 11:50 

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.