Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Jamesy #1
put two SP results together
Hi ,
I have two stored procedures in my MSSQL database.
each looks at the individual operators (loginID) for an admin system, then
checks that ID against the orders in the db.. it then creates an result set
which gives me the loginId, the number of orders that login has placed and
also the total income generated.
The reason there are two is that there are two orders table - a trade one
and a retail one.
I would very much like to be able to have one SP create all results for me
so:
LoginID | RetailNoOrders |RetailIncome |TradeNoOrders | TradeIncome
Any ideas?
James
Jamesy Guest
-
formatting find results in results window or in savedfile
I want a :beer; :-). I want to write an extension that will allow me to format the results returned from a find. I couldn't find anything in... -
Complex join = no results (for a query that shouldreturn results)
I am trying to use a rather complex join that returns many results when the SQL server is queried directly, but returns no results when used on a... -
Sending search results to a results page..with asp
Please help.. very :confused; Ive setup 4 dynamic drop down boxes which populate themselves from my database, this all works fine..The last box... -
Query results don't display properly in results table.IGNORE PREVIOUS
:disgust; I need to display the results of a query. The query runs properly. My problem is having specific results display in specific locations in... -
Query results don't display properly in results table.
:disgust; I need to display the results of a query. The query runs properly. My problem is having specific results display in specific locations in... -
Lionstone #2
Re: put two SP results together
Use a left join.
Loosely -
SELECT L.LoginID, COUNT(R.OrderNo), SUM(R.Income), COUNT(T.OrderNo),
SUM(T.Income)
FROM dbo.UserLogins L
LEFT OUTER JOIN RetailOrders R ON L.LoginID=R.LoginID
LEFT OUTER JOIN TradeOrders T ON L.LoginID=T.LoginID
ORDER BY L.LoginID
Notice I used a specific field in the counts, not *. That's very important
to get the right order counts.
"Jamesy" <NOSPAM@patchworkmedia.co.uk> wrote in message
news:d4t7on$3tu$1@forums.macromedia.com...> Hi ,
> I have two stored procedures in my MSSQL database.
>
> each looks at the individual operators (loginID) for an admin system, then
> checks that ID against the orders in the db.. it then creates an result
> set which gives me the loginId, the number of orders that login has placed
> and also the total income generated.
>
> The reason there are two is that there are two orders table - a trade one
> and a retail one.
>
> I would very much like to be able to have one SP create all results for me
> so:
>
> LoginID | RetailNoOrders |RetailIncome |TradeNoOrders | TradeIncome
>
>
> Any ideas?
>
> James
>
>
Lionstone Guest
-
Jamesy #3
Re: put two SP results together
Cheers - thanks very much
James
"Lionstone" <HIDElionstoneHIDE@HIDEhush.com> wrote in message
news:d4tc93$apr$1@forums.macromedia.com...> Use a left join.
> Loosely -
> SELECT L.LoginID, COUNT(R.OrderNo), SUM(R.Income), COUNT(T.OrderNo),
> SUM(T.Income)
> FROM dbo.UserLogins L
> LEFT OUTER JOIN RetailOrders R ON L.LoginID=R.LoginID
> LEFT OUTER JOIN TradeOrders T ON L.LoginID=T.LoginID
> ORDER BY L.LoginID
>
> Notice I used a specific field in the counts, not *. That's very
> important to get the right order counts.
>
>
> "Jamesy" <NOSPAM@patchworkmedia.co.uk> wrote in message
> news:d4t7on$3tu$1@forums.macromedia.com...>>> Hi ,
>> I have two stored procedures in my MSSQL database.
>>
>> each looks at the individual operators (loginID) for an admin system,
>> then checks that ID against the orders in the db.. it then creates an
>> result set which gives me the loginId, the number of orders that login
>> has placed and also the total income generated.
>>
>> The reason there are two is that there are two orders table - a trade one
>> and a retail one.
>>
>> I would very much like to be able to have one SP create all results for
>> me so:
>>
>> LoginID | RetailNoOrders |RetailIncome |TradeNoOrders | TradeIncome
>>
>>
>> Any ideas?
>>
>> James
>>
>>
>
Jamesy Guest



Reply With Quote

