Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Troubles with SQL - pivot?
07-07-2007, 05:03 PM #1
- Join Date
- Jul 2002
- The sunny side of the Alps
- Thanked 0 Times in 0 Posts
Troubles with SQL - pivot?
I have troubles constructing SQL query and hope some of you could help - I'm using MS SQL 2005. I have a table with data on number of visitors by gender on specific town in a specific country on a specific day.
CREATE TABLE [dbo].[Visitors]( [Country] [nvarchar](50) NULL, [Town] [nvarchar](50) NULL, [Gender] [char](1) NULL, [VisitorNumber] [int] NULL, [VisitorDAte] [datetime] NULL )
SELECT Country, Gender, VisitorDate As [Date of Visit], Sum(VisitorNumber) As [Number of Visitors], (Sum(VisitorNumber)/365) As [Some other Number] FROM Visitors GROUP BY Country, Gender, VisitorDate ORDER BY Country, VisitorDate
I would be very grateful if you could help me solve this problem - it has to be solved with SQL.
Thans a lot,