Click here to Skip to main content
15,881,882 members
Home / Discussions / Database
   

Database

 
AnswerRe: writing a scalar-function Pin
PIEBALDconsult9-Aug-10 15:27
mvePIEBALDconsult9-Aug-10 15:27 
JokeRe: writing a scalar-function Pin
Mycroft Holmes9-Aug-10 16:28
professionalMycroft Holmes9-Aug-10 16:28 
GeneralRe: writing a scalar-function Pin
PIEBALDconsult9-Aug-10 16:48
mvePIEBALDconsult9-Aug-10 16:48 
GeneralRe: writing a scalar-function Pin
Mycroft Holmes9-Aug-10 17:01
professionalMycroft Holmes9-Aug-10 17:01 
GeneralRe: writing a scalar-function Pin
PIEBALDconsult9-Aug-10 17:25
mvePIEBALDconsult9-Aug-10 17:25 
Questionhow to execute stored procedure in a function using sql server 2000 Pin
developerit8-Aug-10 1:15
developerit8-Aug-10 1:15 
AnswerRe: how to execute stored procedure in a function using sql server 2000 Pin
The Digital Worm11-Aug-10 2:17
The Digital Worm11-Aug-10 2:17 
Questionquery optimization Pin
pstsp9117-Aug-10 13:07
pstsp9117-Aug-10 13:07 
Hello, I have a sql (t-sql) question.

I have two tables Orders and Agents.

Each agent does a transaction (bying or selling) and transactions are recorded in Orders table.

Columns in table "Orders":

ItemId, bla, bla, bla, Seller, Buyer


Columns buyer and seller are ID of responsible agent.

Columns in table "Agents":

AgentName, AgentSecondName, ID, bla, bla, bla


NOW i want to display list of all agents alongside with numbers of sold and bought items, in a new table like this:

AGentName, AgentSecondName, AgentId, Bought, Sold

My query is

SELECT AgentName, AgentSecondName, ID
(SELECT COUNT(*)
FROM Orders
WHERE (Seller = Agents.ID)) AS SOLD,

(SELECT COUNT(*)
FROM Orders
WHERE (Buyer = Agents.ID)) AS BOUGHT
FROM Agents

but itąs damn slow with a few millions of records that i have (although its still milliseconds its too slow), any idea how to speed it up?
AnswerRe: query optimization Pin
Mycroft Holmes8-Aug-10 2:04
professionalMycroft Holmes8-Aug-10 2:04 
AnswerRe: query optimization Pin
PIEBALDconsult9-Aug-10 17:21
mvePIEBALDconsult9-Aug-10 17:21 
Question0x00 byte problem while storing binary data to MySQL BLOB via ODBC (C API) Pin
whitesail7-Aug-10 2:24
whitesail7-Aug-10 2:24 
AnswerRe: 0x00 byte problem while storing binary data to MySQL BLOB via ODBC (C API) Pin
Blue_Boy7-Aug-10 5:07
Blue_Boy7-Aug-10 5:07 
GeneralRe: 0x00 byte problem while storing binary data to MySQL BLOB via ODBC (C API) Pin
whitesail7-Aug-10 11:00
whitesail7-Aug-10 11:00 
QuestionCommon Data validation best practice SQL & .Net? Pin
billyjoesunday6-Aug-10 4:54
billyjoesunday6-Aug-10 4:54 
AnswerRe: Common Data validation best practice SQL & .Net? Pin
Mycroft Holmes7-Aug-10 0:39
professionalMycroft Holmes7-Aug-10 0:39 
GeneralRe: Common Data validation best practice SQL & .Net? Pin
billyjoesunday12-Aug-10 5:00
billyjoesunday12-Aug-10 5:00 
GeneralRe: Common Data validation best practice SQL & .Net? Pin
Mycroft Holmes12-Aug-10 12:17
professionalMycroft Holmes12-Aug-10 12:17 
QuestionHow to insert values in to one table, data from two different tables? Pin
sarala.s6-Aug-10 2:15
sarala.s6-Aug-10 2:15 
AnswerRe: How to insert values in to one table, data from two different tables? Pin
thatraja6-Aug-10 2:27
professionalthatraja6-Aug-10 2:27 
AnswerRe: How to insert values in to one table, data from two different tables? Pin
Blue_Boy6-Aug-10 2:32
Blue_Boy6-Aug-10 2:32 
QuestionRe: How to insert values in to one table, data from two different tables? Pin
lovejun7-Aug-10 22:54
lovejun7-Aug-10 22:54 
AnswerRe: How to insert values in to one table, data from two different tables? Pin
Blue_Boy8-Aug-10 6:17
Blue_Boy8-Aug-10 6:17 
Questionsql function Pin
Thanusree Duth5-Aug-10 19:27
Thanusree Duth5-Aug-10 19:27 
AnswerRe: sql function Pin
Blue_Boy6-Aug-10 1:06
Blue_Boy6-Aug-10 1:06 
QuestionCalling Executables from CLR Procedure Pin
Shahzad.Aslam5-Aug-10 6:18
Shahzad.Aslam5-Aug-10 6:18 

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.