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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using COUNT to append to an order number

Author  Topic 

SQLHelper
Starting Member

1 Post

Posted - 2009-05-23 : 14:58:31
I have a record in another table whose primary index is in the format of ordernum-itemno-daycount.

In the following code, I am almost there: I have ordernum-itemno as ItemCode. This is correct. The DayCount is the right number too.

I can't seem to find a way to make ordernum-itemno-daycount.

I am open to a view of a view. Anything!

CREATE VIEW EACHITEM AS
SELECT ([ITEM].[ordernum] + '-' +
CAST(CAST([ITEM].[Itemno] AS INTEGER) AS NVARCHAR))
AS ItemCode, ITEM.ordernum, ITEM.Itemno,
COUNT(ITEM.DayNo) AS DayCount
FROM CUSTFILE RIGHT JOIN (
ORDERS INNER JOIN
ITEM
ON ORDERS.ordernum = ITEM.ordernum
)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-23 : 15:07:50
where's the on condition for right join? also from which tables which filed dayscount is calculated?
Go to Top of Page
   

- Advertisement -