Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need Column Wise Query

Author  Topic 

amitranjan
Starting Member

45 Posts

Posted - 2010-07-22 : 23:32:40
I need to display data on my crystal report from the two tables in format given below.
In the below table C /A are the image categories. 1, 2 are the total number of C or A's processed by user Amit , linked with UserMaster. Similarly, for CMS and PM, then their totals.


---------------------------------------------------------------------------------------

UserName UB CMS PM Total SubTotal
C | A C | A C | A C | A C + A

---------------------------------------------------------------------------------------

Amit 1 2 1 2 1 2 3 6 9

I have two tabled for the same. Usermaster and ImageDetails. Relationship is on verifybyuser(imagedetails),
Userid(usermaster).


Imagedetails data

ImageType ImageCategory VerifiedByUser VerifiedDate
ub C 15 10/11/2007
ub A 1 10/12/2007
cms C 6 10/13/2007
cms A 6 10/14/2007
pm C 6 10/15/2007
pm A 2 10/16/2007



UserMaster data:

Userid Username
1 admin
6 araj
2 AMit





amit Ranjan

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-22 : 23:59:36
check out PIVOT operator
http://technet.microsoft.com/en-us/library/ms177410.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-23 : 03:59:23
This is for dynamic pivot
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2010-07-23 : 07:00:28
quote:
Originally posted by amitranjan

I need to display data on my crystal report from the two tables in format given below.




Crystal Reports is VERY powerful in regards to FORMATTING data. There is no need to format the data in SQL Server.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -