|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.|
||Thread Tools||Display Modes|
Can SQL report multiple columns based on data in one DB column?
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',
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.
|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|