Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
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





























Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 10:41 AM
Report row resutls based on data entry in column. par4724 via OfficeKB.com Excel Discussion (Misc queries) 0 March 26th 08 02:45 PM
Copying columns from multiple sheets in a single sheet based on a column value. [email protected] Excel Programming 1 March 21st 07 09: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 06:35 PM.

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

About Us

"It's about Microsoft Excel"