Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Head-breaking query
Message
From
20/09/2016 16:47:25
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01641137
Message ID:
01641151
Views:
52
>>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform