retagged by
283 views
1 votes
1 votes

Hi Let the table be as,

id Name
1102 n_1102/abc
1102 n_1102/xyz
1102 n_1102/pqr

Please help to get the following data from the table,

for each id, we have many names, but from the name, the first part ie. before '/' is common for all, so if i query as

"Select Name from table where id = 1102", i will get all the details, but i want only the first common part in all the names.

i.e by executing a query for id = 1102, then i should i get name as n_1102 as a single row in the result set.

retagged by

1 Answer

0 votes
0 votes

Finally solved the above issue with the following sql query,

SELECT DISTINCT

SUBSTR(uri, 1, INSTR(uri, '/') - 1) as uri

FROM urBuildingBlockVersionTable where uri != ""

Related questions

0 votes
0 votes
1 answer
3
rayhanrjt asked Jan 6, 2023
717 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 votes
2 votes
1 answer
4
Subhrangsu asked Jun 18, 2022
431 views
Write SQL query to show all employees hired on June 4,1984 (non-default format)emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)