Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Displaying Data In Hierarchy From Single Table..


Hi,

 
    I like to get data from a signle table and arranged in hierarchical(hierarchy) order. What will be my sql script to be able to get the desired result shown below? Please include some explanation as too what script is doing..
   
Table Structure and Sample Data
 
Id    ParentId    Name                    Code       DisplayOrder
1      null           Group 1                G00001           1
2      null           Group 2                G00002           2
3       1             Sub-Group 1         SG0001          1
4       2             Sub-Group 2         SG0002          1
5       3             Sub-Sub-Group 1  SSG001          1
6     null           Group 3                 G00003          3
7      3             Sub-Sub-Group 2   SSG002          2
 
 
Desired Result
Id  ParentId   Level  Name                    ExtendedName                                                DisplayOrder
1      null         1     Group 1                  Group 1                                                               1
3       1           2     Sub-Group 1           Group 1 -> Sub-Group 1                                        1
5       3           3     Sub-Sub-Group 1    Group 1 -> Sub-Group 1 -> Sub-Sub-Group 1          1
7      3            3     Sub-Sub-Group 2    Group 1 -> Sub-Group 1 -> Sub-Sub-Group 2          2
4       2           2     Sub-Group 2           Group 1 -> Sub-Group 2                                        1
2      null         1      Group 2                 Group 2                                                               2
6     null          1    Group 3                  Group 3                                                               3
 
 




View Complete Forum Thread with Replies

Related Forum Messages:
Return The Data From A Table Ordered By Its Hierarchy
How can I create a function that returns hierarchical data from a table with this structure:

- CategoryID
- CategoryName
- CategoryFather

I want to bring the result set like this...

CategoryID | CategoryName | CategoryFather | HierarchicalLevel
1 | Video | 0 | 0
2 | DivX | 1 | 1
3 | WMV | 1 | 1
4 | Programming | 0 | 0
5 | Web | 4 | 1
6 | ASP.Net | 5 | 2
7 | ColdFusion | 5 | 2


How can I do this? Does anybody has a sample code? I need this on SQL Server 2000 and if it's possible (but not too necessary) in SQL Server 2005.

Thanks.

View Replies !
Combine Data In Single Row From Single Table
How can i combine my data in single row ? All data are in a single table sorted as employeeno, date


Code:

Employee No Date SALARY
1 10/30/2006 500
1 11/30/2006 1000
2 10/25/2006 800
3 10/26/2006 900
4 10/28/2006 1000
4 11/01/2006 8000


Should Appear


Code:

EmployeeNo Date1 OLDSALARY Date2 NEWSALARY
1 10/30/2006 500 11/30/2006 1000
2 10/25/2006 800
3 10/26/2006 900
4 10/28/2006 1000 11/01/2006 800

PLEASE HELP I REALLY NEED THE RIGHT QUERY FOR THIS OUTPUT.

THANKS IN ADVANCE

View Replies !
Displaying Related Data From A Table
Dear All,I am using a SQL server database with around 20 columns,allthe columns have numeric values, I want to write an SQL statementwhich does the following:compare each row of the table with all other rows in the table andreturn all the rows that have a difference of + or - 0.5 in eachcolumn, for eg if row1 has values 12.2,13.6,11.4,15.7 correspondingto column1,2,3,4 the sql statement should return all the rows from thetable with values of column 1-4 between12.2- 0.5 to 12.2 + 0.513.6 -0.5 to 13.6+ 0.511.4 -0.5 to 11.4 +0.515.7 -0.5 to 15.7 +0.5so effectively this statement would search for groups of rows thathave matching values(diffence of + or - 0.5)Could anyone suggest how i go about doing this.thank you in advanceharsha

View Replies !
Displaying Data In The Table Of Report On Text Box
Hi,
In my report, I have a table that displays all the data from query. I need to take the value of the 3rd row,2nd column of the table and display in a text box.
I tried to do like:

=ReportItems("TextBox2").Value., where TextBox2 is the 3rd row,2nd column of the table.
This returns just the first row value of the seleted data.  But, I need the 3rd row value.
 
Please let me know how can I acheive this.
 

View Replies !
Subscription With Table Filter Using User!UserID Not Displaying All Data
Hey, Microsoft....is this a bug? 

 

We have SSRS 2005 SP1.  The result set returns data for 50 employees.  I use a table filter: User!UserID = Fields!NtUserName.Value.  I substituted my NtUsername for Fields!NtUserName.Value.  When I generate the report all is well - I can see the data on all of the employees.  From prior testing, I know that when I use the table filter 'User!UserID = Fields!NtUserName.Value' each employee will see only their data.

I want to send a link to all of the employees that will open the last history record.  In Report Manager... report Properties tab....History Window..I have checked 'Allow report history to be created manually' and 'Store all report execution snapshots to report history.'  In the Execution window I selected 'Render this report form a report execution snapshot" and am using a Shared schedule.  I created a Subscription to email me the link. 

When I select 'Create a report snapshot when you click the Apply button on this page' in the Execution tab, all is well - an email is sent and when I click the link I can see the data for all 50 of the employees (I use a page-break by Employee group so there are 50 pages).  However, when the report is generated using the shared schedule, only the first record in the report is displayed and it shows there is only 1 page in the report; and the size of the report is slightly smaller (292 KB vs. 536 KB).  If I create a 'New Snapshot' from the History tab, I can see the data on all of the employees, however, using the link that was emailed when I executed the schedule, I again only see the first employee in the report (perhaps the email does not link back to the history record created in this manner?).

Additionally, when I create a linked report and manually generate it, again only the 1st employee in the result set is in the report.

I've tried many things, including using the NtUsername of 'dbo' and the NtUsername of the account the DataSource is using, but no luck.

Any suggestions???  I am tired of manually executing this report twice a week, but thankful I don't have to do this every hour of the business week!!!

View Replies !
Displaying Multiple Charts Using A Single Dataset
 

Hello,

 

I have the following tables :

 

Area
areano
areaname
 

Locality

locno
areano


 

RequestType               
reqid
reqdtls

 


WebSummit

SummitId

RequestorName

DateOfRequest

reqid

Areano

 

I want to display the total no. of Addition, Removals and Relocations during the past 3 months in a paticular Area.

 

I have written the query for this.

 

select q.[areaname] as Area,

classCount as TotalCount, ReqType

from ( select a.areano,

a.classCount, ReqType

from ( select areano,

count(*) as classCount, reqdtls as ReqType

from WebSummit

join RequestType

on WebSummit.reqid = RequestType.reqid

where date_created >= dateadd(mm, -3, getdate())

group by areano, reqdtls

) a

join WebSummit b

on a.areano = b.areano

group by a.areano,

a.classCount, ReqType

) p

join Area q

on p.areano = q.areano

 

The query works fine and has been tested. Now I want to display this in chart format.

 

 The display should be in a chart format, one for each area showing a bar for each RequestType. 

 

I have placed  "TotalCount" in the Data Fields section and ReqType in Category fields. How do I use the Filter to set an expression so that it displays the data in a seperate chart for each Area.

 

I tried using =Fields!Area.Value and set it to Area1 to display only Area1 values, however the preview shows nothing.

 

Plz help me out.

 

Here's some sample data

 

 

Area

 

AreaNo    AreaName     

1               Area1              

2               Area2               

3               Area 3             

4               Area4              

5               Area5              

6               Area6              

7               Area7              

 

Locality

 

LocNo         AreaNo

1                   1

2                   1

3                   1

1                   2

2                   2

1                   3

2                   3

3                   3

4                   3

1                   4

2                   4

1                    5

2                   5

3                    5

 

 

RequestType

 

reqid      reqdtls

1            Addition

2            Removal

3            Relocate

 

WebSummit

 

SummitId    RequestorName      DateOfRequest       reqid     AreaNo    

1                  John                          12/6/2007                  1           1

2                   Jack                          13/6/2007                 1            1

3                   Bill                             12/6/2007                 2            1

4                   Ben                          12/6/2007                  3           1

5                   Dale                         14/6/2007                  1            2

6                   Evjen                        15/6/2007                  1            2

7                   Fuller                         16/6/2007                 2             2

8                   Jimmy                       16/6/2007                 3             2

9                   Kart                          16/6/2007                  3             2

10                  Fuller                         16/6/2007                 3             2

 

 

Regards,

Vidya

View Replies !
Retrieving Hierarchical Data From A Single Table
I would like to retrieve a hierarchical list of Product Categories from a single table where the primary key is a ProductCategoryId (int) and there is an index on a ParentProductCategoryId (int) field. In other words, I have a self-referencing table. Categories at the top level of the hierarchy have a ParentProductCategoryId of zero (0). I would like to display the list in a TreeView or similar hierarchical data display control.Is there a way to retrieve the rows in hierarchical order, sorted by CategoryName within level? I would like to do so from a stored procedure. Example data:ProductCategoryID CategoryDescription ParentProductcategoryID ParentCategoryDescription Level------------------------------------------------------------------------------------------------------------------------------------------------1                           Custom Furniture     0                                                                             02                           Boxes                     0                                                                             03                           Toys                       0                                                                             04                           Bedroom                 1                                    Custom Furniture                15                           Dining                     1                                    Custom Furniture                16                           Accessories            1                                    Custom Furniture                17                           Picture Frames        6                                    Accessories                       28                           Serving Trays           6                                    Accessories                       29                           Entertainment          1                                    Custom Furniture                110                         Planes                     3                                    Toys                                  111                         Trains                      3                                    Toys                                  112                         Boats                      3                                    Toys                                  113                         Automobiles             3                                    Toys                                  114                         Jewelry                    2                                    Boxes                                115                         Keepsake                2                                    Boxes                                116                         Specialty                 2                                    Boxes                                1Desired output:Custom Furniture     Accessories          Picture Frames          Serving Trays     Bedroom     Dining     EntertainmentBoxes     Jewelry     Keepsake     SpecialtyToys     Automobiles     Boats     Planes     Trains

View Replies !
Help With Creating SQL Statement To Get Data From Single Table...
Hi, I'm having some difficulty creating the SQL Statement for getting some data from a table:
I have the following table of data
__User___Votes___Month
__A_______14______2__A_______12______3__A_______17______4__A_______11______5
__B_______19______2__B_______12______3__B_______15______4
 
I want to beable to pull out the total number of votes a user has had over a period of months.
eg Total up each users users votes for months 4 and 5
that would give:
__User____TotalVotes
___A________28___B________15
An added complecation is that user B does not have any data for month 5
Any help or pointers would be fanstatic
Many thanks

View Replies !
Comparing Data In Two Consecutive Rows From A Single Table
I'm trying to come up with an elegant, simple way to compare twoconsecutive values from the same table.For instance:SELECT TOP 2 datavalues FROM myTable ORDER BY timestamp DESCThat gives me the two latest values. I want to test the rate ofchange of these values. If the top row is a 50% increase over the rowbelow it, I'll execute some special logic.What are my options? The only ways I can think of doing this arepretty ugly. Any help is very much appreciated. Thanks!B.

View Replies !
Loading The Different Language Data From Excel File To The Single Table
can anyone help me to solve this problem
i have created a ssis package to load the data from excel file to the table, but we are getting the data in different language ie in french,english and in china after loading the data when we view the data it is showing as junk characters for chinese data but we are able to see other language data ie french and english.
so please tell me how to solve that
reply to my mail id(sandeep_shetty@mindtree.com)
 

View Replies !
Data Flow Task - Multiple Columns From Different Sources To A Single Table
Hi:


I have a data flow task in which there is a OLEDB source, derived column item, and a oledb destination. My source is a SQL command, that returns some values. I have some values, that I define in the derived columns, and set default values under the expression column. My question is, I also have some destination columns which in my OLEDB destination need another SQL command. How would I do that? Can I attach two or more OLEDB sources to one destination? How would I accomplish that? Thanks


MA2005

View Replies !
Create Table Hierarchy??
Hi, with the three tables below, I want to add relationships so that each Grandparent can spawn many parents and each Parent can spawn many children.

I keep getting an error when I try to connect them. Could I get some help creating that hierarchy please?

Thanks in advance!

Here are the tables:

CREATE TABLE [dbo].[GrandParent] (
[GPID] [int] IDENTITY (1, 1) NOT NULL ,
[GPName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Parent] (
[PID] [int] NOT NULL ,
[GPID] [int] NOT NULL ,
[PName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO


CREATE TABLE [dbo].[Child] (
[CID] [int] NOT NULL ,
[PID] [int] NOT NULL ,
[ChName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO


--PhB

View Replies !
How To Get The Data In A Hierarchy?
 
How can I get the data from a table that stores hierarchical information keeping the right order and hierarchy levels?
 
I also need to specify a first level....let me explain.
 
Table: Sites
Id (PK)
Title
Url
ParentId

 
If I have something like this:
 
1 | Test | http://localhost | NULL
2 | Sub-Test | http://localhost/subtest | 1
3 | SecondItem | http://anotherServer | NULL
4 | ChildOfSub-Test | http://localhost/subtest/child | 2
 
 
And I specify that I want all child items below the Id 2, it must return:
Id | Title | Url | ParentId | Depth
2 | Sub-Test | http://localhost/subtest | 1 | 0

4 | ChildOfSub-Test | http://localhost/subtest/child | 2 | 1
 
 How can I do this? I've saw some examples with CTEs, but they always return all of the items.

View Replies !
Fetch Data From Hierarchy In XML.
My problem is that my:hustyp)[1] only fetches the first occurace of this tag. In my xmlfile this field is a repeating table created in infopath 2007. How do I manage to get the rest dynamically.

------XML-file---------------------------------------
<my:group1>
<my:group2>
<my:hustypTF>5</my:hustypTF>
</my:group2>
<my:group2>
<my:hustypTF>6</my:hustypTF>
</my:group2>
<my:group2>
<my:hustypTF>7</my:hustypTF>
</my:group2>
</my:group1>
-----------------------------------------------------

------T-SQL for fetching data from XML datatype------
WITH xmlnamespaces('http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-01-15T13:29:33' AS my)
SELECT FormData.value('(/my:xxx/my:Formular/my:group1/my:group2/my:hustyp)[1]', 'varchar(99)') AS IdFastBet
FROM MinaDekl
CROSS APPLY FormData.nodes('(/my:xxx/my:Formular/my:group1/my:group2/my:hustyp) as TempTab(testTab1)
-----------------

View Replies !
Trying To Enforce Ref Integrity On Hierarchy Table Relationship
I've got a table that includes:CREATE TABLE [dbo].[Content] (  [Id] int IDENTITY(1, 1) NOT NULL,  [ParentId] int NULL,
I'm wanting to make sure that a ParentId must be in the table as Id someplace else.  When I try to do it by making it a foreign key  get the error:
--------------- SQL ---------------
ALTER TABLE [dbo].[Content]ADD CONSTRAINT [Content_fk3] FOREIGN KEY ([Id])   REFERENCES [dbo].[Content] ([ParentId])   ON UPDATE NO ACTION  ON DELETE NO ACTIONGO
---------- ERROR MESSAGE ----------
There are no primary or candidate keys in the referenced table 'dbo.Content' that match the referencing column list in the foreign key 'Content_fk3'.Could not create constraint. See previous errors.
 
Any ideas? 
 
ALTER TABLE [dbo].[Content]ADD CONSTRAINT [Content_fk3] FOREIGN KEY ([Id])   REFERENCES [Content].[dbo] ([ParentId])   ON UPDATE NO ACTION  ON DELETE NO ACTIONGO
 

View Replies !
Retrieve Manager/Subordinate Hierarchy From Self-Referencing Table
Hi SQL GurusCould anyone please explain how the following stored procedure can beamended to retrieve Subordinates in alphabetical order ?The example below simply retrives records in the order in which theywere entered.It sounds very easy but I can't sort it out ?The following code was taken from Narayana Vyas Kondreddi's website(http://vyaskn.tripod.com/index.htm)Consider the employee table of an organization, that stores all theemployee records. Each employee is linked to his/her manager by amanger ID.CREATE TABLE dbo.Emp(EmpIDintPRIMARY KEY,EmpNamevarchar(30),MgrIDintFOREIGN KEY REFERENCES Emp(EmpID))GOCREATE NONCLUSTERED INDEX NC_NU_Emp_MgrID ON dbo.Emp(MgrID)GOINSERT dbo.Emp SELECT 1, 'President', NULLINSERT dbo.Emp SELECT 2, 'Vice President', 1INSERT dbo.Emp SELECT 3, 'CEO', 2INSERT dbo.Emp SELECT 4, 'CTO', 2INSERT dbo.Emp SELECT 5, 'Group Project Manager', 4INSERT dbo.Emp SELECT 6, 'Project Manager 1', 5INSERT dbo.Emp SELECT 7, 'Project Manager 2', 5INSERT dbo.Emp SELECT 8, 'Team Leader 1', 6INSERT dbo.Emp SELECT 9, 'Software Engineer 1', 8INSERT dbo.Emp SELECT 10, 'Software Engineer 2', 8INSERT dbo.Emp SELECT 11, 'Test Lead 1', 6INSERT dbo.Emp SELECT 12, 'Tester 1', 11INSERT dbo.Emp SELECT 13, 'Tester 2', 11INSERT dbo.Emp SELECT 14, 'Team Leader 2', 7INSERT dbo.Emp SELECT 15, 'Software Engineer 3', 14INSERT dbo.Emp SELECT 16, 'Software Engineer 4', 14INSERT dbo.Emp SELECT 17, 'Test Lead 2', 7INSERT dbo.Emp SELECT 18, 'Tester 3', 17INSERT dbo.Emp SELECT 19, 'Tester 4', 17INSERT dbo.Emp SELECT 20, 'Tester 5', 17GOCREATE PROC dbo.ShowHierarchy(@Root int)ASBEGINSET NOCOUNT ONDECLARE @EmpID int, @EmpName varchar(30)SET @EmpName = (SELECT EmpName FROM dbo.Emp WHERE EmpID = @Root)PRINT REPLICATE('-', @@NESTLEVEL * 4) + @EmpNameSET @EmpID = (SELECT MIN(EmpID) FROM dbo.Emp WHERE MgrID = @Root)WHILE @EmpID IS NOT NULLBEGINEXEC dbo.ShowHierarchy @EmpIDSET @EmpID = (SELECT MIN(EmpID) FROM dbo.Emp WHERE MgrID = @Root ANDEmpID > @EmpID)ENDENDGOEXEC dbo.ShowHierarchy 1GO---President------Vice President---------CEO---------CTO------------Group Project Manager---------------Project Manager 1------------------Team Leader 1---------------------Software Engineer 1---------------------Software Engineer 2------------------Test Lead 1---------------------Tester 1---------------------Tester 2---------------Project Manager 2------------------Team Leader 2---------------------Software Engineer 3---------------------Software Engineer 4------------------Test Lead 2---------------------Tester 3---------------------Tester 4---------------------Tester 5

View Replies !
Mind Bender: Hierarchy/Many To Many/Temporal Data
I've posted this in the microsoft news group but just noticed the compnewsgroups. What's the difference anyways?This one is a tricky one so I'm interested in seeing what all you gurus haveto say.I'm trying to put a resume into a database. There are only three reports(see below).I suspect that the best structure for a resume database is as follows:CompanyCompanyID Autonumber Primary KeyCompanyName TextCompanyDetails TextSkillSkillID Autonumber Primary KeySkillParentID NumberSkillName TextExperienceExperienceID Autonumber Primary KeyCompanyID numberExperienceStart Date/TimeExperienceStop Date/TimeDescription TextDetail MemoKeywords MemoExperienceSkillExperienceSkillID Autonumber Primary KeyExperienceID NumberSkillID NumberPercent NumberSo each Experience is linked to a number of skills through theExperienceSkill Junction table. Also, the Skills are a hierarchy using theadjacency set model. (I know some people will tell me to use the nested setmodel but I'm only interested in it if the code for maintaining it isprovided and it can be shown how to produce the reports).I like surrogate keys since this will likely be deployed through a Webapplication but I'll listen to anyone who can cook up a data structure andprovide the queries to render the reports.I suspect that the above data schema is ok but writting the queries hasproven to be a challenge.Ideally, i'd like to figure out a structure so that the queries are just abunch of SELECT queries with no procedural code.///////////////////////Report 1: Skill Summary (by node)///////////////////////This report is trickier than it looks since the total (T1) for each sectionare not plain totals due to the overlapping of assignments. Example, if thecandidate used FoxPro 2.5 for 1m and 2.6 for 1m, that doesn't mean they have2m of FoxPro since the two assignments could have had the same begin and enddates. T2 is just a plain total.Report 1A (From Root):T1 T2Management 8m 14mProject Management 5m 5mTechnical Leadership 3m 3mTraining/Mentoring 2m 6mProgramming 8m 23mFoxPro 7m 17mFoxPro 2.0 DOS 1m 2mFoxPro 2.5 DOS 1m 2mFoxPro 2.6 DOS 2m 2mVisual FoxPro 3.0 4m 5mVisual FoxPro 6.0 5m 6mVisual Basic 2m 2mVisual Basic 3.0 1m 1mVisual Basic 6.0 1m 1mAccess 2m 4mReport 1B (From FoxPro):FoxPro 7m 17mFoxPro 2.0 DOS 1m 2mFoxPro 2.5 DOS 1m 2mFoxPro 2.6 DOS 2m 2mVisual FoxPro 3.0 4m 5mVisual FoxPro 6.0 5m 6m//////////End Report 1///////////////////////Report 2: Experience Summary (by node and all else)///////////////////////This report is a list of work experiences that fall underneath one treebranch. The tricky part here is that the work experiences have leaf skillattached to them. That is FoxPro 2.0 DOS can be assigned to an experiencebut not FoxPro (the parent of FoxPro 2.0 DOS). But we want to show theparent records of the skill anyways.Report 2A (From FoxPro): This will list all the experiences that have aFoxPro skill.Company: Banana CompanyPosition: Programmer AnalystDate: Jan 1, 1995-Feb 1, 1995Desription: Jumped around for a whileSkills:Programming, FoxPro, FoxPro 2.0 DOS, FoxPro 2.5 DOSManagement, Training/MentoringCompany: Apples CompanyPosition: Programmer AnalystDate: Jan 1, 1995-Feb 1, 1995Desription: Ate beans and weiners.Skills:Programming, AccessManagement, Training/Mentoring............Report 2B (All else but FoxPro): This is all the experences that are not inthe above report.{same as above but just different entries come forward}//////////End Report 2///////////////////////Report 3: Timeline by (node)///////////////////////This is a list of dates over which a skill was used. The tricky part here isthat the work experiences overlap so we have to merge many of the timeperiods. We don't want to show any overlapping dates on this report.Report 3A (from FoxPro): We need to show the dates for FoxPro and the skillunder FoxPro in one report.Jan 1, 1995 to Feb 1, 1995March 15, 1996 to April 25, 1996//////////End Report 3Thanks for sharing your ideas about this database problem!If you wish to contact me directly, take the X's away from my email address.Darcy

View Replies !
Aggregation In A Hierarchy Involving Non-leaf Data.
NOTE: I apologize to anyone (especially moderators) who may notice that I am basically repeating a question that was already posted by me in another recent thread. The reason why I am reposting is because I want to filter my question down to its crux because the other question may not have been asked in the most clear way.
 
The Question:
 
The sceanrio is this.
(1) I have a sales person dimension with a hierarchy.
(2) In this hierarchy, Bill and Ted roll up to John.
(3) Bill sells 10 units, Ted sells 8 units, and John sells 5 units.
 
When you process this hierarchy, what would you expect the total to be for John?
(A) 23, which is the sum for Bill, Ted, and John
or
(B) 18, which is the sum of Bill and Ted only and overwritting John's number
 
I say (A) and I think most will choose the same, and all the examples I've been reflects (A).
 
However, in my simple cube I get (B).
 
Is there a setting I need to adjust to get (A)?
 
 
 

View Replies !
Displaying A Table
I'm not sure how to go about this and need some help.I've got a data extract rather than a properly structure table in SQL.It looks something like below:Name: Item:John BallJohn RacketPaul BallJim GloveJim BallWhat sort of script can I run that will return each name once and thenthe Items in as many columns needed to list them all?I.e. so that it will look likeName: Item1 Item2John Ball RacketPaul BallJim Glove BallRegards,Ciarán

View Replies !
Displaying A Value Only Once In A Table
Hi,

I have a table with a row to display the count of all records with a specified specialty. The count is displaying the correct value, however the row is being displayed 20 times as there are 20 records.

I would like this row to only be displayed once. I'd appreciate being pointed in the right direction as to how to do this.

Thanks,
John

View Replies !
Displaying Sum At The Bottom Of The Table
neo writes "hi
i am a beginner at sql
this query confuses me...

q:A LIST OF SERVICE TRANSACTIONS(WITH A FULL DESCRIPTION OF THE SERVICE) ON A PARTICULAR DAY ALONG WITH THE NAMES OF THE CUSTOMER AND THEIR ROOM NUMBERS.THE TOTAL AMOUNT TRANSACTED NEEDS TO BE DISPLAYED AT THE BOTTOM OF THE LIST

REQD TABLES ARE
SERVICES,TRANSACTIONS AND RESERVATIONS...

all i can do was this answer...

SELECT T.TRANID,S.*,R.FNAME,R.LNAME,R.ROOMID FROM SERVICES AS S ,RESERVATIONS AS R,TRANSACTIONS AS T
WHERE S.SERNO=T.SERNO AND T.CUSTID=R.CUSTID ORDER BY T.TRANID
COMPUTE SUM(S.SERCHAR)

is there a better way to display in the same table the sum too?"

View Replies !
Displaying Text From A Table:
Hi, this is a simple question:

I have a field called school_year that has 11 values in it as follows:

0 2000-2001
1 2001-2002
2 2002-2003
3 2003-2004
4 2004-2005
5 2005-2006
6 2006-2007
7 2007-2008
8 2008-2009
10 2009-2010

When I query this field it returns a value between 0-10 . In my report I need to display this as a text(example: "2006-2007" if 6 was returned). Currently I'm using a Switch function. I was wondering is there is an easier way to do this using a lookup table or something like that.
Thanks..

View Replies !
Displaying Last Record In SQL Database Table
Got a question here and as I am no expert programmer, this should be easy for you gurus. I have this fairly generic code I've created where I return data from an SQL table in a DataList control. I want to take it to the next level and return only the last record in the table, but I am unsure of how to do that. Perhaps I shouldn't even be using a DataList control, I'm not sure.

View Replies !
Displaying DMX Query Results In Table...
Hye Friends,
                  I'm using a DMX query to get some predictions out of my MiningModel

my DMX query is as follows :

SELECT
  predict([x SalaryPredictor].[Emp Gross],20),predict([x SalaryPredictor].[Emp Basic],20)
From
  [x SalaryPredictor]

This query is returning me 2 objects of type expressions in my Dataset.
The problem is when I try to drag these 2 fields in my Table i get a "#Error" value

I executed the query in 'Data' tab and found that data is getting returned is a tree like format where "Expression" is at top & values expected ar its child nodes.

I also found out that the returned objects are actually AdomdDataReader , but i'm not able to write a expression to get its values in my tables....

I want to display the values in the following format....

_____________________________
|    Emp gross    |     Emp basic     |
---------------------------------------------------
| predicted val 1  |  predicted val 2   |
---------------------------------------------------
|  ....                  |  .....                  |
-- -------------------------------------------------


can anybody help me out in this ????...

Thanks in advance !!!

View Replies !
Please Help Displaying Specific Data
Hi I have used the create user wizard to create a registration page my table stores the user details and user id. I am also using the login wizard to create a log in page . I now want to display the details of the currently logged in user usind details view and allow them to view and edit their details. where and how do i create the session varible anh how do I wtire the sql select statement say select first name from table1 where (the userid I stored earlier in a table when the user registered ) = (this should be the currently logged in user'id). I am a novice so I would appreciate code snippets
My code in asp page for the details looks like this
 asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1"
Height="50px" Width="125px">
<EditRowStyle BackColor="#CCFF99" />
<AlternatingRowStyle BackColor="#FFCCFF" />
</asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="SELECT [FirstName], [LastName], [City], [Listing] FROM [UserDetails] WHERE ([UserId] = @UserId)">
</asp:SqlDataSource>
 
novice This shows no data when I test it. I have tried the folling in the .vb page no luck.
 Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound
Dim UserId As Integer = Me.DetailsView1.DataItem("userID")Session("_UserID") = UserId
End Sub

View Replies !
Displaying One Data Record
Hi all, this is a very basic question of diplaying a data. on my aspx page I have datasource that will return only ONE record.
  <asp:SqlDataSource ID="sdsCategoryName" runat="server" ConnectionString="<%$ ConnectionStrings:KaruselaConnectionString %>"        SelectCommand="SELECT Title FROM tbh_Categories WHERE CategoryID=@categoryID  ">        <SelectParameters>            <asp:QueryStringParameter DefaultValue="-1" Name="CategoryID" QueryStringField="id" Type="int32"/>        </SelectParameters>    </asp:SqlDataSource> 
on the server side I would like to manipulate the title of the page according to the data returned from the query:
 and on the behind code if (!this.IsPostBack && !string.IsNullOrEmpty(this.Request.QueryString["ID"]))
{
DataView dv2 = (DataView)sdsCategoryName.Select(arg);
this.Title = string.Format(this.Title, dv2.Table.Columns[0].ToString());
dv2.Dispose();
}
  of course it doesn't work. my question is this. do we really have to put the query datasource on the client side?and secondly, how can I view the recorsd I recieves from the query?Thanks for the help. 

View Replies !
Displaying Data - Question
Dont laugh;
How do I create a simple sqlcommand in C# that shows data. I have the code for VB but I a missing something in the converstion. I know SQL but I dont get the simple steps of displaying data. I have got all of the Visual Basic stuff down I just need help with doing it by hand in C#.
or point my to a URL so that I can get  the code.
Thanks

View Replies !
Matrix Displaying Data
 

I'm sorry if this is a stupid question, but this is my first matrix report.
 
I am using a stored procedure that generates the following data:
 
Item     Color     Size    Qty
Shorts  Tan       32        0
Shorts  Tan       34        2
Shorts  Tan       36        2
Shorts  Tan       38        0
 
The matrix displays as follows:
                          34    36  
Shorts     Tan       2      2
 
 
I would like it to display as follows:
 
                          32    34    36    38
Shorts     Tan       0      2      2      0
 
It seems that by default (I used the wizzard to create the report) that the zeros are being suppressed.  How can I get them to display?
 
Thanks
 

View Replies !
Help In Displaying Data From Cursor.
i m trying to display data from cursor.. but i think i m wrong wth the syntax..

i m doing tht in procedure..

i think dbms_output:put_line dsnt work in sql 2000 ..or may b  a problem of Print statemnt instead.

help me out..thx in advance

View Replies !
Displaying Data Problem
 

I fixed all the free text stuff but now I have another problem. I created a web app one page to enter data and anoter to display it. I have a multiple row text box and if you enter something with returns it it when you display the data it ignores the returns and puts everything on the same line  BTW the column type is text
 
example
 
this
"want to hest this out.
========================
 
now I am going to put in some test data and see how it comes out
 
finished"
 
will come out like this
"want to hest this out.========================now I am going to put in some test data and see how it comes out finished"

 
how do you fix this?

View Replies !
Displaying Data Horizontally
In sql server, multiple instances of data default to a row display or vertical. I need a set of data in sql2005 to view horizontally so I can us it in a crystal report. Here is my issue.
gift.HonorKey, gift.HonorName, gift.HonorId
1211 Smith 1222
1244 Owens 4155

I need for the data to read like this:
HonorKey1, HonorKey2, HonorName1, HonorName2, HonorId1, Honorid2
1211 1244 Smith Owens 1222 4155

the table name is gift_view

I would like to be able to create a view in sql analyzer, then save as an SQL View
My direct email is jackfam@comcast.net

View Replies !
Displaying Duplicate Data
Hi. Not sure which section this request needs to be put in, but i'm relatively new to SQL.

I have 1 table which contains an user_id (autonumber), user_name, and user_profile.

I have 2 other tables:
config_version (cv) and config (c)

These two tables both access the user table (us) to view the user_id (which is required).

I want to be able to view the user_names for both "cv" and "c" on a seperate page. Using the code below, i'm lost. I created what i wanted in MS Access with the use of a 2nd table (this might be easier to understand than my rant above). However, I don't want a 2nd table.

Can someone provide me with a function, or the "answer" to my problem?

Highlighted Blue - just there to fill in the front page with data (not wanted)
Highlighted Green - doesn't work, but was my first attempt

Code:
public function ShowQuotes
Dim objConn
Dim objADORS
Dim strSQL
Dim row

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = strConn
objConn.Open

Set objADORS = CreateObject("ADODB.RecordSet")
strSQL = "Select top 50 "
strSQL = strSQL & " cv.config_version_id as cvid, cv.configuration_id as cid, cv.version_number as cnum"
strSQL = strSQL & ", cv.status as cstat, cv.total_price as cprice, cv.modification_date as cmod, cv.version_description as cvrem"
strSQL = strSQL & ", c.remarks as qrem"
strSQL = strSQL & ", p.prod_description as pdesc, p.version as pvers, p.status as pstat"
strSQL = strSQL & ", cust.customer_name as custname"
strSQL = strSQL & ", us.user_nt_login as modname"
strSQL = strSQL & ", us.user_name as usname"
' strSQL = strSQL & ", cv.user_id as modname"
strSQL = strSQL & " from tbl_config_version as cv, tbl_configuration as c, tbl_product as p, tbl_user as us, tbl_customer as cust"
strSQL = strSQL & strWhere 'SETS RESULTS TO BE UNIQUE
strSQL = strSQL & " and us.user_id = c.user_id"
strSQL = strSQL & " and cv.configuration_id = c.configuration_id"
strSQL = strSQL & " and c.product_id = p.product_id"
strSQL = strSQL & " and c.customer_id = cust.customer_id"
strSQL = strSQL & strOrderBy & ";"

Image: www.mcdcs.co.uk/TT.jpg

View Replies !
Displaying NULL Values In The Destination Table
 

Dear Members,
 
I extracted data from a flat file using SSIS package and load them into destination table. One column contains no data. Data type of that column is varchar(9). I want to display "NULL" values in that column.
 
I used LOOK up transformation and used the following query.
 

SELECT PassThroughRouting =
 CASE PassThroughRouting
WHEN 'NULL' THEN  'NULL'
END
FROM EPICWareTable
 
But it gives a error message.
 
Does any body can help me?
 
Thanks

View Replies !
Linked Server Not Displaying Table Details
I have created a linked server using my local SQL2005. The linked server can be seen as a linked server, but the database can not been expanded to see the tables, stored procedures, views, and other details regarding the linked server. The only method that I have found that will allow me to see all the details is to use XP's Remote Desktop Connection to access the database. Has anyone else experienced this problem, if so, how did you resolve it?

View Replies !
Arithmetic Expressions And Data Displaying
Hello, Im new to SQL. Im currently having a table called Daily with 5 columns. TesterNames,Activity,Hours_given,Hours_used and Delta. I have grabbed the data for the first three colums from another table called Tester. For Hours_used I supposed to get the data from another server after i get the access but mean time i just put my own data so that i can check the value of Delta. Data for Delta column should be as below.
Delta = Hours_given - Hours_used
So How do I do the codings for this expression and display it in the same table. Output I need as below:
TesterNames        Activity       Hours_given       Hours_used          Delta
abc                       A                    5                       6                     -1
def                        B                    7                       6                      1
 
I have used
INSERT INTO Daily ( TesterNames,Activity,Hours_given)
SELECT ( Tester_ID,Weekday_Day,EntityWDD)
FROM Tester
and the first 3 columns are filled with the data needed. But when I use
INSERT INTO DAILY(Delta) 
SELECT Delta = Hours_given - Hours_used FROM DAILY
The output was like below
TesterNames        Activity       Hours_given       Hours_used          Delta
abc                       A                    5                       6                    
def                        B                    7                       6                     
Null                     Null                  Null                   Null                    -1
Null                     Null                  Null                   Null                     1
Help me . thank you.

View Replies !
Displaying Data From Database In Textboxes
Im trying to display data from a database based on an input value. The value in the Label12.Text which is("hotmail") is the input value thats stored in the database, this value is been searched for in the strSQL.
 Dim strSQL As String = "SELECT Name FROM Jobseeker WHERE Email='" & Label12.Text & "' "
strSQL = Label5.Text
 
the code builds successfully, but Label5.Text appears blank.
 
 

View Replies !
Data Not Displaying (in DataList) From SQL On GoDaddy
Everything works great on my development box.  I am using GoDaddy for production (ASP.Net v2, SQL 2000).
I am not receiving any errors, so I am stumped; no data from the database is displaying on the GoDaddy pages.
I updated the connection string in web.config to this:

< add name="snsb" connectionString="
Server=whsql-vXX.prod.mesaX.secureserver.net;
Database=DB_42706;
User ID=username;
Password=pw;
Trusted_Connection=False" providerName="System.Data.SqlClient" / >

But I am unsure if this is the issue??  Any insights?  This is the page I am working on: www.sugarandspicebakery.com/demo/bakery/default.aspx.  So, the page displays fine, but it should be showing data from the database.  This particular page uses a DataList with ItemTemplate.  There is definitely data in the database, and I have even ran the same exact query from the code using the Query Analayzer on GoDaddt and it returned results
I know there isn't much info to go by, but I am hoping someone has some insight since I have been trying to figure this out for days now!
Thank youJennifer

View Replies !
Displaying SQL Server Data Properties In ASP
Does anyone know how to display the properties of a column / data field in ASP? Thanks!

View Replies !
Displaying Data From A Certain Date Range
Hey all, hopefully this question is in the right spot. I'm writing a .NET app talking to a MS SQL 2000 DB. I have two date range input boxes, and I want to display the data (probably in a dataGrid) from those 2 certain dates. How do I go about this with my SQL server??

My DB table has a date field that I would use to search for the data between those two user specified dates. Any tips, examples, etc. would be greatly appreciated!!!

View Replies !
How Can Avoid Displaying Data Using A Cursor ??
I defined a stored procedure with a cursor inside for updating data.
When I call it from an MSAccess client, it fails.
When I execute it directly in a ISQL/w windows, it doesn`t fail but it displays me the data (wich is the reason for failing from MSAccess).
Do somebody know if I could do it without displaying data in the screen ??

View Replies !
Displaying Data From Multiple Rows On 1 Row
I would like to display data from one column on multiple rows in one row.

Example:

Name Pet
David Dog
Dawn Dog
Dawn Cat
Pete Mouse
Pete Cat
Pete Dog

I would like the result to do the following:

David Dog
Dawn Dog Cat
Pete Dog Cat Mouse

I will not know the row values ahead of time.

View Replies !
Problem Displaying Data The Way I Want On A Report- Pls Help!
I have output from a query in the following format:

metric             value

abc                1514.98

def                 878.95

ghi                 618.98

 

I need to present a series of ratios on my report based on set formulae:

eg liquidity ratio= abc/ghi*100

gearing ratio=def/ghi*100 etc

Basically I need to be able to reference both the metric and value where I want on the report.

 

Any ideas?

 

 

 

View Replies !
Displaying Group Headers Even When No Data?
I have a table where I need to display groupings of information.  If there isn't any data for a given group, I still need to include that group and say "no applicable data" or somesuch underneath it.  Any way of doing this?

View Replies !
(Urgent) Help Need In Displaying The Data In My Report....
Hi all.
  I want to display the data from this table (data provided below in my report)
PlanId, ParticipantId, FundId, FundNames, Loans,PortfolioId, Act1, TotAct1, Act2, Totact2 etc.. Until act20, totAct20
 
18752 1041 Columbia Funds Trust VI: Columbia Small Cap Value Fund I; Class A Shares NULL NULL NULL BB 425.32 CT 0.00 DV 0.00 GL 17.40 TF 0.00 WD 0.00 OT 0.00 EB 442.72 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
 
18752 6204 Columbia Funds Series Trust: Columbia Small Cap Index Fund; Class A
Shares NULL NULL NULL BB 120.09 CT 0.00 DV 4.04 GL 2.10 TF 0.00 WD 0.00 OT 0.00 EB 126.23 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
 
18752 10302 Columbia Funds Series Trust: Columbia Marsico 21st Century Fund; Class A Shares NULL NULL NULL BB 119.59 CT 0.00 DV 1.69 GL 10.41 TF 0.00 WD 0.00 OT 0.00 EB 131.69 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 

18752 11010 Columbia Acorn Trust: Columbia Acorn International Select; Class A Shares NULL NULL NULL BB 125.06 CT 0.00 DV 0.33 GL 8.83 TF 0.00 WD 0.00 OT 0.00 EB 134.22 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 

18752 11024 Columbia Acorn Trust: Columbia Acorn International; Class A Shares NULL NULL NULL BB 126.85 CT 0.00 DV 0.77 GL 10.07 TF 0.00 WD 0.00 OT 0.00 EB 137.69 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
 
I will have around 10 -15 records depending on how many funds the user has... and i want my report to look like this
 
InvestmentName                    Act1 (BB)   Act2(CT)     Act3(DV) Act4(TF) ..Act20
 FundNames                         TotAct1       TotAct2      TotAct3      TotAct4 .. Totact5 so the data will be displayed for each fund in different rows..
 
 
I am storing the value acroynms and what they stand for a different table and i know there are 20 acroynms and i need to the description of that acronymn to show in the heading... How can i do it...
I am trying to right a sproc for it...
Any help will be greatly appreciated... if you need more information.. pls feel free to ask
 
Regards
Karen
 
 

View Replies !
Displaying Data That Is HTML In Field.
OK, so I have been tasked to create a report from Quality Center.  QC saves the description field in HTML.
When I created the report to display that field I get all the text with the HTML mark-up.

Is there a way to strip that out or actually have reporting services render the html?

Thanks a Mil!

View Replies !
Displaying User Entered Data
I have a procedure that allows a user to enter two dates to run a query. I would like to display those dates on the generated report underneath the title. "5-01-07 to 5-31-07" How would I do this?

View Replies !
Displaying Data Across When Data Goes Down! Has To Be Easy!
I have a table with:Name, Qtr, AmountTom, 1, 100Bob, 1, 123Tom, 2, 234Bob, 2, 456Steve, 1, 565Steve, 2, 898I want the query to return:Name, Qtr 1 Amount, Qtr 2 AmountBob 123 456Steve 565 898Tom 100 234I can't seem to figure this out! Any help would be appreciated!!Sheila

View Replies !
Displaying Parent / Child / Grandchild Data
I am working on an ASP.NET site to display information about authors and books.  I'm working on the Author page right now and I'm having trouble getting it to display the data I want.
I'm trying to do everything with declarative controls and as little code-behind as possible.
I have a datasource on the main page that selects the Author data and provides this to a FormView.  Inside the FormView is another datasource that takes the AuthorID as a parameter and selects the list of books, which is provided to a DataList.
Inside the DataList I display some limited Book information.  I also want to display some child items of the Book (grandchildren of the author), for example other authors who contributed to that book, or alternative titles.  I have tried using datasources in each DataList row with a parameter set to the BookID, and it works just great, but the response time is just not acceptable.  Each datasource of possible several dozen is making its own call to the database and it's just too slow.
If I use code I can grab all the data in one operation and use relations in the DataBinding event (I believe) to select the data I want, but this is a bit cumbersome and I expect will cause trouble if I want to eventually use an ObjectDataSource.
Incidentally, on a display-only page I use the XMLDataSource and it works great, but I need read-write access on the Edit page.
Is there a good way to do what I'm trying to do?
 
Thanks,
Graham

View Replies !
Displaying Data In Datagrid From A Normalized Set Of Tables
Ok, I'm fairly new to .NET and even newer to the whole database concept.  But, don't run away yet, I'm no idiot and I shouldn't have too hard of a time understanding your responses if you're kind of enough to give them.  That being said, here's my dilemma:I'm trying to make a database of all the movies I own, the actors in them and the genre (s) they belong to. I have a set of tables that are in the 2NF (I think).  I have a movies table, an actors table, a genres table, and two tables called movies_actors and movies_genres with primary-foreign key relationships to pull it all together (e.g. movie_id 1 has two entries in movies_genres, one for Action and one for Drama). My problem arises that when execute my monster query to pull ALL the data on one movie, I get a row returned for every combination of Genres and Actors in a movie.  Example:movie_id            movie_title            comments            actor_first         actor_last            genre_name1                        Casino                  blah blah            Robert               DeNiro               Action1                        Casino                  blah blah            Robert               DeNiro               Drama1                        Casino                  blah blah            Joe                  Pesci                  Action1                        Casino                  blah blah            Joe                  Pesci                  Drama And here's the query that produced that:1 SELECT movies.movie_title, movies.comments, actors.actor_first,
2 actors.actor_last, genres.genre_name
3 FROM movies INNER JOIN movies_actors ON movies.movie_id = movies_actors.movie_id
4 INNER JOIN actors ON movies_actors.actor_id = actors.actor_id
5 INNER JOIN movies_genres ON movies_genres.movie_id = movies.movie_id
6 INNER JOIN genres ON movies_genres.genre_id = genres.genre_id
So, I want to put all the actors for one movie into the same cell in the datagrid (same with the genres) and still keep it sortable by actor or genre.  Is this possible with the .NET 2.0 datagrid?  Do I have some fundamental misunderstanding of how my tables should be structured?  Am I just really far off and acting like a n00b?

View Replies !

Copyright İ 2005-08 www.BigResource.com, All rights reserved