>>This distributor wants a listing of locations to be delivered by day
>>
>>
>>Sunday Monday Tuesday etc
>>loc a loc b loc d
>>loc j loc k etc etc
>>
>>
>>the table contains the daynumber Sunday =1, and the location,
>>
>>Can it be done in one query?
>
>Naomi's answer is likely to suffice. But just curious, can you post the DDL for the table(s) involved?
I tried Naomi's answer. I got blank values in some of the column/row cells and couldn't figure out how to prevent that.
Here is the structure:
The important columns are storecode( location) and daynumber (1 = Sunday)
CREATE TABLE [dbo].[dropschedule](
[storecode] [char](11) NULL,
[daynumber] [decimal](1, 0) NULL,
[num_drops] [decimal](2, 0) NULL,
[route] [char](3) NULL,
[driver_1] [char](2) NULL,
[condition] [bit] NULL,
[cfrom] [datetime] NULL,
[cthru] [datetime] NULL,
[commission] [decimal](3, 0) NULL,
[each_cycle] [bit] NULL,
[t_when] [decimal](2, 0) NULL,
[schday] [char](3) NULL,
[adduser] [char](4) NULL,
[adddate] [datetime] NULL,
[addtime] [char](8) NULL,
[lckstat] [char](1) NULL,
[lckuser] [char](4) NULL,
[lckdate] [datetime] NULL,
[lcktime] [char](8) NULL,
[adjustment] [money] NULL,
[commtype] [char](1) NULL
) ON [PRIMARY]
GO
I'm half way through doing this the old-fashioned way with datatables- aka filling up cursors- but I'd prefer to have a query that did it.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.