Showing posts with label relationship. Show all posts
Showing posts with label relationship. Show all posts

Monday, March 19, 2012

Getting relationship data

Hi
I am trying to create a query or set of querys, which will allow me to retrieve the relationship data of a database. In sql Server 2000 the user can create diagrams which show these relationships, what i want to be able to do is get this data, but i am h
aving trouble finding a starting place. Could anyone point me in the right direction?
Thanks in advance
You can start by querying INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS view.
If you are interested in viewing the reference constraints that exist in
your database, you can do:
SELECT o1.name AS "tablename",
OBJECT_NAME( f1.constid ) AS "constraintname",
OBJECT_NAME( f1.rkeyid ) as referencedtable
FROM sysobjects o1
LEFT OUTER JOIN sysconstraints c1
ON o1.id = c1.id
AND c1.status &3 = 3
LEFT OUTER JOIN sysforeignkeys f1
ON c1.constid = f1.constid
WHERE o1.type = 'u'
ORDER BY "referencedtable", "tablename" ;
Anith

Friday, March 9, 2012

Getting most recent row from one-to-many relationship

I have two tables, Admission and RecordSummary. The Admission table holds
one row for each resident at our facility and the RecordSummary table holds
one row for each admission the resident has (could be more than 1). They
are linked using a Register Number, which is a 6 digit number. The
RecordSummary table has a column named AdmissionNo, which contains the
admission number.
How can I SELECT a resident and their most recent (i.e. highest AdmissionNo)
RecordSummary table row?
Thanks,
DrewDrew
select * from Admission c
join (select resident ,max(orderdate)orddate
from RecordSummary group by resident )
as der on der.resident =c.resident
order by c.resident
"Drew" <drewDOTlaingATswvtc.dmhmrsas.virginia.gov> wrote in message
news:%23EYeajbeGHA.4532@.TK2MSFTNGP02.phx.gbl...
>I have two tables, Admission and RecordSummary. The Admission table holds
>one row for each resident at our facility and the RecordSummary table holds
>one row for each admission the resident has (could be more than 1). They
>are linked using a Register Number, which is a 6 digit number. The
>RecordSummary table has a column named AdmissionNo, which contains the
>admission number.
> How can I SELECT a resident and their most recent (i.e. highest
> AdmissionNo) RecordSummary table row?
> Thanks,
> Drew
>|||Thanks!
Drew
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:ecXPnpbeGHA.3900@.TK2MSFTNGP05.phx.gbl...
> Drew
> select * from Admission c
> join (select resident ,max(orderdate)orddate
> from RecordSummary group by resident )
> as der on der.resident =c.resident
> order by c.resident
>
>
> "Drew" <drewDOTlaingATswvtc.dmhmrsas.virginia.gov> wrote in message
> news:%23EYeajbeGHA.4532@.TK2MSFTNGP02.phx.gbl...
>

Wednesday, March 7, 2012

getting last result in report builder

Hi friends
i need to advise on "filters" on a report builder report.
say i've 2 entities patient and test results. (1-many relationship).
as you all know ,when creating report model, based on data types,VS automatically creates aggreates attributes for us(like "First ..date","Last date" etc.,) which is cool.

our client what to create a report where they want to get last test result for each patient.
i thought its simple and i added patient name (from Patient entity) and "date of result"(i dragged "Last date of result" from this attribute) up to here everything works fine but the test result which is a string ,i get all test results!! but we want only last test result.

i tried to add a filter like "date of result = Last date of result" but still get all results but i get corrects "dates" though.

how do we get "LAST" result for each patient ?
Thanks for ur help.any ideas on this much appreciated guys.
it should be simple but cant figure out yet how to do this ?|||no ideas any one ?
plz let me know if you need any further info|||I don't think you will achieve this with just setting parameters, you will need to tailor your query. Is your query sql or mdx?|||hi there
am creating report builder report (based on a report model)|||any one has ideas on this one ?
Thanks

getting last result in report builder

Hi friends
i need to advise on "filters" on a report builder report.
say i've 2 entities patient and test results. (1-many relationship).
as you all know ,when creating report model, based on data types,VS automatically creates aggreates attributes for us(like "First ..date","Last date" etc.,) which is cool.

our client what to create a report where they want to get last test result for each patient.
i thought its simple and i added patient name (from Patient entity) and "date of result"(i dragged "Last date of result" from this attribute) up to here everything works fine but the test result which is a string ,i get all test results!! but we want only last test result.

i tried to add a filter like "date of result = Last date of result" but still get all results but i get corrects "dates" though.

how do we get "LAST" result for each patient ?
Thanks for ur help.any ideas on this much appreciated guys.
it should be simple but cant figure out yet how to do this ?|||no ideas any one ?
plz let me know if you need any further info|||I don't think you will achieve this with just setting parameters, you will need to tailor your query. Is your query sql or mdx?|||hi there
am creating report builder report (based on a report model)|||any one has ideas on this one ?
Thanks

getting last result in report builder

Hi friends
i need to advise on "filters" on a report builder report.
say i've 2 entities patient and test results. (1-many relationship).
as you all know ,when creating report model, based on data types,VS automatically creates aggreates attributes for us(like "First ..date","Last date" etc.,) which is cool.

our client what to create a report where they want to get last test result for each patient.
i thought its simple and i added patient name (from Patient entity) and "date of result"(i dragged "Last date of result" from this attribute) up to here everything works fine but the test result which is a string ,i get all test results!! but we want only last test result.

i tried to add a filter like "date of result = Last date of result" but still get all results but i get corrects "dates" though.

how do we get "LAST" result for each patient ?
Thanks for ur help.any ideas on this much appreciated guys.
it should be simple but cant figure out yet how to do this ?|||no ideas any one ?
plz let me know if you need any further info|||I don't think you will achieve this with just setting parameters, you will need to tailor your query. Is your query sql or mdx?|||hi there
am creating report builder report (based on a report model)|||any one has ideas on this one ?
Thanks