Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.
-
J. Joshi #1
Counting 1st Record only
Hello,
I am trying to write a query which will identify only
those members who have used either one or more services in
a given year. 1 MemberID can have 1 or more UnitID's. This
means that if I group the report by UnitID's, I will see
multiple MemberID's. I just want to see 1 MemberID based
on utilization (that being >=1) based on first use in a
given calander year.
However, that member should be repeated the next year if
he/she has used the service 1 or more times. I am just
trying to count my members using services irrespective of
the number of times they have used it.
Here is a data-set I am CURRENTLY generating:
Yr Mth MemberID MemType UnitID Type
==============================================
2003 April 7044 AS C Renew
2003 April 7044 AS L Change
2003 June 7044 AS C Change
2003 June 7044 AS L Renew
2004 May 7044 AS C Change
2003 April 5000 NA CL Current
2003 April 5000 NA WSR New
2003 June 5000 NA WSR Change
2004 May 5000 NA CL Change
2004 May 5000 NA WSR Renew
Here is the results set I want to see:
Yr Mth MemberID MemType UnitID Type
==============================================
2003 April 7044 AS C Renew
2004 May 7044 AS C Change
2003 April 5000 NA CL Current
2004 May 5000 NA WSR Renew
Any idea on how would I acieve this result set. I am on
SQL Query Analyzer ver.8.00.194
Thanks so much.
Joshi
J. Joshi Guest
-
How can i retrieve record ONLY From 300 - 400 in amillion Record Table?
HI all Thanks for your time.. I have a question here.. How can i retrieve record ONLY From XXX - XXX in a million Record Table? eg. I have a... -
counting down in a for
Hi all there is probably a much better way of doing all this i am working on the checkResults sub. it should find the pollerAudit log created... -
Find record w/ conditions met in the same child record
I'll use 2 files to demonstrate my question. The first file is Animal. It has 4 fields. Id (serial number) ZooId (number) Name (text) Food... -
Stop adding record in subform after record count = 1
Can someone help in in what to put after the THEN statment to allow one entry if the Record count is =>1 in the Before insert or should I set the... -
Adding a new record when the record source is a query.
Hello All, I have a form that runs a query. The reason it runs on a query is because prior to it opening I have a form from which you can pick... -
Anith Sen #2
Re: Counting 1st Record only
Here is a generalized t-SQL method for such requirements,
SELECT *
FROM tbl
WHERE keycol = (SELECT TOP 1 keycol
FROM tbl t1
WHERE t1.dupcol = tbl.dupcol
ORDER BY t1.keycol DESC)
Here the keycol is the column/set of columns which can uniquely identify a
row within the group & dupcol is the column which is duplicated across the
rows.
--
- Anith
( Please reply to newsgroups only )
Anith Sen Guest



Reply With Quote

