SQLTeam.com | Weblogs | Forums

Stored Procedure Query Report and Display Horizontally

tsql
sql2008
sql2012
sql2014
sql2008r2

#1

Hi everyone,

I need help with my sql report generation.

please refer to the screenshot below.

Table 1 - This is my actual db table.

I want to create a report that will display the items horizontally (please refer to Table2 - Report / Screen Output).

Thanks,


#2

What if there are two HDs or three monitors? What would it look like then? What if there are two computers?


#3

Hi gbritton,

HARD DISK, MEMORY, MONITOR, CPU CASE and OTHER are my categories.

Whenever the user adds an item, they will need to select under what category the items belongs to.

so if there are multiple items, the report that i want will be like this :slight_smile:

HARDISK | CURR | EXRATE | TYPE | MEMORY | CURR | EXRATE | TYPE | .....
120 - USD - 1.33 - PREPAID - 200 - USD - 1.44 - PREPAID....
300 - USD - 1 - CASH - 120 - USD - 1.44 - CASH...
150 - USD - 1.35 - CASH - 200 - USD - 1.44 - CASH ....
220 - USD - 1.32 - CASH - 200 - USD - 1.44 - CASH ....


#6

hello everyone,

any idea how to present the report horizontally?

thanks


#7

If you just want one text line per PC, FOR XML PATH('') will do it
If you want multiple columns instead, you'll need dynamic SQL.

How would you like it?


#8

hi,

I want it in multiple columns. how can I do it?


#9

to start please post

CREATE TABLE statement
INSERT INTO statement to populate sample data