A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Charts and Charting in Excel
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Can SQL report multiple columns based on data in one DB column?



 
 
Thread Tools Display Modes
  #1  
Old September 18th 15, 07:51 PM posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default Can SQL report multiple columns based on data in one DB column?




Greetings Everyone,
I am working with SQL in Excel to access a small database.
One of the columns (named "Tagindex") contains numbers 1-11.

I would like to create a report that contains separate columns for each Tagindex number.

Each record contains Timestamp, Tagindex, Max value, Min value and average value so what I want will look like this.

Tag1 Timestamp Tag1 max Tag1 Min Tag1 Avg Tag2 Timestamp Tag2 max ETC......

I can pull up a table that has all the data in 5 columns but what I would like would have about 44 columns.

Can SQL create this report?



The code I use to obtain the 5 columns looks like this.


SELECT convert(char(10),HistoricalData.DateAndTime,120) AS 'Groupby date', Max(HistoricalData.DateAndTime) AS 'Timestamp',
avg(HistoricalData.Val/10) AS 'Avg Value',
Max(HistoricalData.Val/10) AS 'Max Value', Min(HistoricalData.Val/10) AS 'Min Value',
(HistoricalData.TagIndex)

FROM rsview.dbo.HistoricalData HistoricalData

WHERE (HistoricalData.DateAndTime>?) AND (HistoricalData.DateAndTime<?) AND (HistoricalData.Val <>0)

GROUP BY convert(char(10), HistoricalData.DateAndTime,120),(HistoricalData.Ta gIndex)

ORDER BY convert(char(10), HistoricalData.DateAndTime,120)


The "?" parameters are date related values on the Excel worksheet.



Thanks Glen





























Ads
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a report sheet based on 1 column's data dunnowhatimdoin Excel Worksheet Functions 1 September 18th 10 10:08 AM
Report row results based on the last data entry in a column par4724 via OfficeKB.com Excel Discussion (Misc queries) 2 March 27th 08 09:41 AM
Report row resutls based on data entry in column. par4724 via OfficeKB.com Excel Discussion (Misc queries) 0 March 26th 08 01:45 PM
Copying columns from multiple sheets in a single sheet based on a column value. [email protected] Excel Programming 1 March 21st 07 08:05 AM
sum a column based on multiple other columns being true sofia Excel Programming 4 August 8th 06 04:06 AM


All times are GMT +1. The time now is 01:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2004-2017 ExcelBanter.
The comments are property of their posters.