Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 calculated column

Author  Topic 

Rose88
Starting Member

2 Posts

Posted - 2010-06-11 : 17:09:35
Hey,
I want to add the code 1st so u can understand me.
this is one query:
SELECT   dbo.tblMedicine.MedicineNum, COUNT(dbo.tblOrders.MedicineNum) AS count, AVG(dbo.tblOrders.Quantity) AS avg
FROM dbo.tblOrders INNER JOIN
dbo.tblMedicine ON dbo.tblOrders.MedicineNum = dbo.tblMedicine.MedicineNum
GROUP BY dbo.tblMedicine.MedicineNum, dbo.tblOrders.Quantity
HAVING (COUNT(dbo.tblOrders.MedicineNum) > @param)
ORDER BY count DESC

now there's a column in tblMedicine named: noOfOrders and I want it to be equals for COUNT(dbo.tblOrders.MedicineNum):
tblMedicine.noOfOrders=COUNT(dbo.tblOrders.MedicineNum)
how can I do this??

I tried to do this in transaction but it didn't work!!
Can u help me?!??!

Sachin.Nand

2937 Posts

Posted - 2010-06-12 : 06:41:13
But then what about (COUNT(dbo.tblOrders.MedicineNum) > @param) in the HAVING clause?



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

Rose88
Starting Member

2 Posts

Posted - 2010-06-12 : 10:37:43
it should be the noOfOrders but i put it so, so I can see some outputs.
it should be like this:
(tblMedicine.noOfOrders>@param)
Go to Top of Page
   

- Advertisement -