Hi,
I have a table
SQL> select * fom temp;
FID TID RN
---------- ---------- ----------
1 2 1
1 3 2
1 4 3
2 1 1
2 5 2
3 1 1
3 6 2
3 7 3
4 1 1
Now i want the o/p like this
FID TID's
------ ---------------------------
1 2,3,4
2 1,5
3 1,6,7
4 1
Any Help?
thank you
1 1306
Hi,
I have a table
SQL> select * fom temp;
FID TID RN
---------- ---------- ----------
1 2 1
1 3 2
1 4 3
2 1 1
2 5 2
3 1 1
3 6 2
3 7 3
4 1 1
Now i want the o/p like this
FID TID's
------ ---------------------------
1 2,3,4
2 1,5
3 1,6,7
4 1
Any Help?
thank you
-
-
SELECT * FROM
-
(SELECT fid,sn, row_number() over(partition by fid order by fid,sn desc) rn from
-
(SELECT fid, SUBSTR(SYS_CONNECT_BY_PATH(rid,','),2) sn FROM
-
(select fid,rid,row_number() OVER(PARTITION BY fid ORDER BY FID) rn FROM
-
(select 1 as fid, 2 as rid from dual
-
UNION
-
select 1, 3 from dual
-
union
-
select 1, 4 from dual
-
UNION
-
select 2, 1 from dual
-
UNION
-
SELECT 2, 2 from dual
-
UNION
-
SELECT 3, 4 from dual
-
UNION
-
SELECT 3, 6 FROM Dual))
-
CONNECT BY rn = PRIOR rn - 1
-
AND PRIOR fid = fid
-
ORDER BY sn desc, fid desc))
-
WHERE rn = 1
-
-
--output
-
-
FID SN RN
-
1 4,3,2 1
-
2 2,1 1
-
3 6,4 1
-
-
The above query looks slightly complex becuase i dont have a table structure and had to make it work using dual statements for the data.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Syed Ghayas |
last post by:
Hi,
I've been having problem writing a cookie. Everything goes ok but when I
supply the .Path property to "/" It just write the cookie when there is no
cookie present, but when I try to update the...
|
by: acdevteam |
last post by:
Hello Everyone,
We are a dev team very new to Access, and so far we have gotten
excellent support from this group. We have a question about writing a
query. Here is the situation:
We have a...
|
by: vijay.db |
last post by:
Hi Group,
I'm running DB2 UDB Enterprise Edition V7.1 in AIX 4.3.3.0. And
database backups goes to the TSM server. We have the following TSM
Client API installed in the server:
...
|
by: weird0 |
last post by:
Hi!
On the recommendation of one of the MVP's on this group....... I tried
writing parametrized queries. But the fucking thing does not work and
it does not update the data in the table.
I...
|
by: rmr531 |
last post by:
First of all I am very new to c++ so please bear with me. I am trying
to create a program that keeps an inventory of items. I am trying to
use a struct to store a product name, purchase price,...
| |
by: grabit |
last post by:
Hi Mary
this is the problem child (query)
<!---Query db for page info--->
<cfquery name="showtopics" datasource="parrots">
SELECT categories.catID, threads.threadID, threads.posttype,...
|
by: navneetkaur |
last post by:
can any1 help me plz in writing sql query.....m problem is i have to combine two tables
in 1 table m having desicode
'd in other table m having desicode 'd division name
i jst want to display all...
|
by: manoj9849967222 |
last post by:
Hi All
I have a problem with query.
I have designed a simple query which sould give me itemwise total qty sales during a given period.
the fields in the query are
startdate,...
|
by: viki1967 |
last post by:
Problem with query ASP and MySQL
Hi there.
I have this fields in the tbl (mysql) :
- ID (unique)
- user_name (text)
- Date (yyyy-mm-dd)
- Description (text - case A or B or C -)
|
by: vapanchamukhi |
last post by:
hi....
i want to write the query
select * from user where name = "richard"; in perl
the string richard i have taken that in the variable $name.
i have written the query as below
$sth =...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |