May 28, 2008 at 3:07 am
Hi there,
i am implementing something in SQL where i need one function which can perform same thing as First function in Access.
If we have different record for some particular reference number then i need to select first record. Access have First function but SQL doesnt have it.
i have query something like this.
select referece, date, first(ward), first(something)
from table X
group by reference, date
i can use TOP 1 in SQL but group by makes confusion.
any suggestion?
thanks,
vijay
May 28, 2008 at 3:43 am
You need first from where?
Mercury is the first from the Sun, but it's the last planet for aliens coming from outside of Solar system. Or second planet for us, sitting on Earth.
So, where are you counting from?
_____________
Code for TallyGenerator
May 28, 2008 at 3:50 am
Hi,
it is first from table X. I have 4 fields in the table.
Table X -
reference date ward code
1001 2/2/2 EQE q22
1001 2/8/9 EQQ q22
Here i want to select for any reference first record. I hvae other record with difference reference number.
i need to implement query which is available in access as below.
select reference, date, first(ward), first(code)
from table X
group by reference, date
i just need SQL version of this query. we dont have first function in sql. i got the TOP to use but coz of group by it doesnt match number of record.
thanks,
vijay
May 28, 2008 at 4:41 am
Do you have a criterian for the First of ward and code as the first occurrence according to the date column i.e. for the minimum date?
May 29, 2008 at 1:32 am
The same question was posted in SQLS2005 forums
http://www.sqlservercentral.com/Forums/Topic507496-338-1.aspx
and received some answers there.
Please don't cross-post. Always choose one forum where you will post your question, based on what you need to solve.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply