Need query for this logic..
Hi,
Need a SQL query to achieve this..
Ex:
Select object_name from user_objects where object_name in('EMP','DEPT')
You will get 2 table names.
DEPT
EMP
Now I want to count how many records are there in each table
Output should be like
DEPT 4
EMP 13
Please let me know how can we write it ?
Thanks in Advance
Devender
You need to create a function to cout rows.
Here is an example
CREATE OR REPLACE
FUNCTION get_rows (
t_owner IN varchar2 default user,
t_name IN varchar2
RETURN integer
IS
outVal integer;
BEGIN
select null
into outVal
from dba_tables
where ( owner=t_owner )
and ( table_name=t_name );
execute immediate 'select count(*) from '||t_owner||'.'||t_name into outVal;
RETURN outVal;
EXCEPTION
WHEN no_data_found THEN
return null;
END;
/And here is the query.
Processing ...
select owner,object_name,get_rows(owner,object_name) n_rows
from dba_objects
where object_name in('EMP','DEPT')
Query finished, retrieving results...
OWNER OBJECT_NAME ROWS
SCOTT EMP 14
SCOTT DEPT 4
2 row(s) retrieved
Similar Messages
-
Hi
I need a procedure 4 this logic,
Need to get 32+ inputs in procedure of same type varchar2,
If comp_id !=360
insert 32 inputs in table column-> value using custom-id
Note:
Column : brand-code,value,custom_name using custom_id
brand-code gets from comp-id from another table
i/p- from procedure comp_id and 32 inputs
This 32 inputs should use varray cocept
end if;
ex:
table 1
brand_code custom-id value editble
table 2
custom-id custom-name
Could you please share ur suggestionsCreate or replace procedure cdm_cl_proc is
v_sqnum number(3);
cursor c1 is
select dcn, pp_code from d_cl_ext;
Cursor c2 is
Select t_code, s_date, area_chrg, rc_pct from d_c_p_ext;
Begin
for v1 in c1
Loop
update d_cl set pp_code = v1.pp_code
where dcn=v1.dcn;
select d_sqnum into v_sqnum from d_cl
where dcn=v1.dcn;
For v2 in c2
Loop
Update d_c_p set area_chrg= v2.area_chrg, rc_pct=v2.rc_pct
Where t_code= v2.t_code and s_date = v2.s_date
and d_sqnum = v_sqnum;
if mod(c2%rowcount,1000)=0 then
commit;
end if;
End loop;
if mod(c1%rowcount,1000)=0 then
commit;
end if;
End loop;
Commit;
End;
I amable to load the data when dcn is matched but, if the dcn is not matched no data found error is coming. can u suggest error handling for this. -
Hi,
I need sequence for autogenerate of code
Table 1
id code
We need to autogenerate code for every new entity of id
ex:
id code
sbi sbi001
hsb hsb002
xyz xyz003
And
ex:
id code
sbi s001
hsb h002
xyz x003You can use a Sequence and Trigger in combination like this
create table t
id varchar2(10)
, code varchar2(25)
create sequence t_seq;
create or replace trigger t_trig before insert on t for each row
declare
l_seq integer;
begin
select t_seq.nextval into l_seq from dual;
:new.code := :new.id || to_char(l_seq, 'fm099');
end;
insert into t (id) values ('sbi');
insert into t (id) values ('hsb');
insert into t (id) values ('xyz');
select * from t; -
Hi
table1
id cus_id val
boi p gh
hdc s vc
123 p xy
123 s xz
123 m xb
123 ll zx
Note: 123 is default values
o/p
id cus_id val
boi p gh
boi s xz
boi m xb
boi ll zx
hdc s vc
hdc p xy
hdc m xb
hdc ll zx
123 p xy
123 s xz
123 m xb
123 ll zxHi,
Pleaes check this:
WITH t AS
(SELECT 'boi' id, 'p' cus_id, 'gh' val FROM DUAL
UNION ALL
SELECT 'hdc', 's', 'vc' FROM DUAL
UNION ALL
SELECT '123', 'p', 'xy' FROM DUAL
UNION ALL
SELECT '123', 's', 'xz' FROM DUAL
UNION ALL
SELECT '123', 'm', 'xb' FROM DUAL
UNION ALL
SELECT '123', 'll', 'zx' FROM DUAL),
tt AS
(SELECT *
FROM t
WHERE id = '123')
SELECT a.id, b.cus_id, b.val
FROM t a, tt b
WHERE a.id <> '123' AND a.cus_id <> b.cus_id
UNION ALL
SELECT * FROM t
order by 1;
Cheers,
Manik. -
Report Builder Version:10g
Hi Guys Good Morning to one and all
I have a table Named Onlsuvdet which captures the answers from
an online survey front end which has multiple choice questions.
the table structure is as follows
create table onlsuvdet(shloid number,questno char(5),respo1 char(5),respo2 char(5));
and the sample data is as follows
SHLOID QUEST RESPO RESPO
9315 1 2
9315 2 3
9315 3 4
9315 3 5
9315 4 1
9315 5 2
9315 5 1
Now i want the result as follows
shlogid quest1 quest2 q3 q4 q5
9315 2 3 4,5 1 2,1
So my requirement is a query which displays this data as above.
Please helpppp
Any help will be appreciated :)
Thanks & RegardsHi,
user123 wrote:
Report Builder Version:10g
Hi Guys Good Morning to one and all
I have a table Named Onlsuvdet which captures the answers from
an online survey front end which has multiple choice questions.
the table structure is as follows
create table onlsuvdet(shloid number,questno char(5),respo1 char(5),respo2 char(5));Thanks for posting the CREATE TABLE statement. That helps.
Why are you using the CHAR datatype, rather than VARCHAR2? CHAR is nothing but trouble.
and the sample data is as follows
SHLOID QUEST RESPO RESPO
9315 1 2
9315 2 3
9315 3 4
9315 3 5
9315 4 1
9315 5 2
9315 5 1Always post your data in a form people can use to re-create the problem and test their solutions. for example:
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '1 ', '2 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '2 ', '3 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '3 ', '4 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '3 ', NULL, '5 ');
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '4 ', '1 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '5 ', '2 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '5 ', NULL, '1 ');I'm making a lot of guesses about the data. for example, I'm guessing there will never be more than 2 rows with the same shloid and questno.
Why do you have 2 columns, respo1 and respo2? Is exactlyly one of them always NULL? If respo1 is NULL, will there always be another row with the same shloid and questno, but with a NULL respo2?
Now i want the result as follows
shlogid quest1 quest2 q3 q4 q5
9315 2 3 4,5 1 2,1Be consistent with the column names; either call them all questn (like I did below) or call them all qn.
So my requirement is a query which displays this data as above.Perhaps something like this:
WITH joined_data AS
SELECT r1.shloid
, r1.questno
, RTRIM ( r1.respo1 || ',' || r2.respo2
) AS respo
FROM onlsuvdet r1
LEFT OUTER JOIN onlsuvdet r2 ON r1.shloid = r2.shloid
AND r1.questno = r2.questno
AND r1.respo1 IS NOT NULL
AND r2.respo2 IS NOT NULL
SELECT shloid
, MAX (CASE WHEN questno = '1 ' THEN respo END) AS quest1
, MAX (CASE WHEN questno = '2 ' THEN respo END) AS quest2
, MAX (CASE WHEN questno = '3 ' THEN respo END) AS quest3
, MAX (CASE WHEN questno = '4 ' THEN respo END) AS quest4
, MAX (CASE WHEN questno = '5 ' THEN respo END) AS quest5
FROM joined_data
GROUP BY shloid
I hope this answers your question.
If not, point out a few places where the query above gets the wrong results. Post the correct results (formatted, between \ tags, as explained in the FAQ
http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ
) and explain how you get the correct results from the given data. Correct or add to the sample data that I psoted, if necessary. -
Hi,
Below is my table with columns like a,b,c
a b c
1 null null
null 2 null
null null 3
I need output like a b c
1 2 3Hi,
Here's one way
SELECT MIN (a) AS a
, MIN (b) AS b
, MIN (c) AS c
FROM my_table;
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places. If you changed the query at all, post your code.Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
consider this situation,
Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.
my tables are from northwind:
[orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
[orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
i tried some but it is not exact, it gives wrong result.
select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
having count(od.ProductID) >1) pd
join
(select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
on sd.CustomerID=pd.CustomerIDHi,
I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
tables for your review.
In my example I have included:
1. A customer which has purchased the same product on the same day, using the same ship 3 times,
2. Another example the same as the first but the third purchase was on a different day
3. Another example the same as the first but the third purchase was a different product
4. Another example the same as the first but the third purchase was using a different "ShipVia".
You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
Please let me know if I have missed any requirements.
Hope this helps:
CREATE TABLE #ORDERS
OrderID INT,
CustomerID INT,
OrderDate DATETIME,
ShipVia VARCHAR(5)
CREATE TABLE #ORDERS_DETAILS
OrderID INT,
ProductID INT,
INSERT INTO #ORDERS
VALUES
(1, 1, GETDATE(), 'ABC'),
(2, 1, GETDATE(), 'ABC'),
(3, 1, GETDATE(), 'ABC'),
(4, 2, GETDATE() - 4, 'DEF'),
(5, 2, GETDATE() - 4, 'DEF'),
(6, 2, GETDATE() - 5, 'DEF'),
(7, 3, GETDATE() - 10, 'GHI'),
(8, 3, GETDATE() - 10, 'GHI'),
(9, 3, GETDATE() - 10, 'GHI'),
(10, 4, GETDATE() - 10, 'JKL'),
(11, 4, GETDATE() - 10, 'JKL'),
(12, 4, GETDATE() - 10, 'MNO')
INSERT INTO #ORDERS_DETAILS
VALUES
(1, 1),
(2, 1),
(3, 1),
(4, 2),
(5, 2),
(6, 2),
(7, 3),
(8, 3),
(9, 4),
(10, 5),
(11, 5),
(12, 5)
SELECT * FROM #ORDERS
SELECT * FROM #ORDERS_DETAILS
SELECT
O.CustomerID,
OD.ProductID,
O.ShipVia,
COUNT(O.ShipVia),
DATENAME(DW, O.OrderDate) AS [Shipped Day]
FROM #ORDERS O
JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
DROP TABLE #ORDERS
DROP TABLE #ORDERS_DETAILS -
How to form a query for this requirment
Hi Friends,
I have a database table in which I store the employee data along with his phone number. Now this row of data can repeat for different phone number depending on if it is office phone or home phone or cell phone.
But in the output of query, I need name of empoyee and other three columns namely "Home Phone", "Office Phone" and "Cell Phone".
If employee has three rows for each kind of phone, then in the result of query all three columns for phone numbers should be filled, otherwise as many columns should be filled with data as different phone numbers employee has.
Can any one please post SQL query for this scenario ?
Thanks in AdavanceI cannot imagine, that second and third query are
under any circumstances faster as first one, but i
can imagine that they are slower You stated that query without the inline view can only be faster. Did you check on optimizer plans or use tkprof to verify your claim?
A quick check on those two selects
SELECT object_id, object_type, object_name
FROM user_objects;
SELECT object_id, object_type, object_name
FROM (SELECT object_id, object_type, object_name
FROM user_objects)
;didn't show any changes in the explain plan unter 10g1.
C. -
I want sql query for this output
hi guys
could u tell how can i write sql query for this out put
i have one table like this
ID ACCOUTID TAX
1 1 A
2 1 B
3 2 C
4 2 D
5 3 E
7 NULL F
8 NULL G
MY OUT PUT MUST BE LIKE THIS
ID AID TAX
2 1 A
4 2 D
7 NULL F
8 NULL G
HERE IN THIS OUTPUT I SHOULD HAVE
MAXIMAM ID VALUE FOR A REPEATED AID VALUES
AND
THE ROWS AID VALUES IS NULL ALSO MUST PAPULATED IN THE OUTPUT.
I KNOW ONE SOLUTION LIKE THIS
SELECT MAX(ID),AID,TAX
FROM TABLE T
GROUP BY AID,TAX
UNION ALL
SELECT ID, AIC,TAX
FROM TABLE T
WHERE AID IS NULL;
BUT I WANT SAME RESULT WITH OUT USING LOGICAL OPERATORS.
COULD U PLZ TELL A SOL.Will this help:
SQL> with t as
2 (
3 select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
4 select 2, 1, 'B' from dual union all
5 select 3, 2, 'C' from dual union all
6 select 4, 2, 'D' from dual union all
7 select 5, 3, 'E' from dual union all
8 select 7, NULL, 'F' from dual union all
9 select 8, NULL, 'G' from dual
10 )
11 --
12 select id, ACCOUTID AID, Tax
13 from
14 (
15 select t.*
16 ,count(1) over (partition by t.ACCOUTID) cn
17 ,row_number() over (partition by t.ACCOUTID order by id desc) rn
18 from t
19 )
20 where cn > 1
21 and (rn = 1 or ACCOUTID is null)
22 /
ID AID T
2 1 B
4 2 D
8 G
7 F
-- If I leave out the OR condition then you'll get this:
SQL> ed
Wrote file afiedt.buf
1 with t as
2 (
3 select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
4 select 2, 1, 'B' from dual union all
5 select 3, 2, 'C' from dual union all
6 select 4, 2, 'D' from dual union all
7 select 5, 3, 'E' from dual union all
8 select 7, NULL, 'F' from dual union all
9 select 8, NULL, 'G' from dual
10 )
11 --
12 select id, ACCOUTID AID, Tax
13 from
14 (
15 select t.*
16 ,count(1) over (partition by t.ACCOUTID) cn
17 ,row_number() over (partition by t.ACCOUTID order by id desc) rn
18 from t
19 )
20 where cn > 1
21* and rn = 1
SQL> /
ID AID T
2 1 B
4 2 D
8 G
--which follows the description you've given, but not the output -
Require a Message mapping for this Logic.
Hi Experts,
I require a Message mapping for this Logic.
In the Source there are 4 fields and, the Target side, the fields should appear like this.
Source Structure- File
Record
|-> Header
Order_No
Date
|-> Item
Mat_No
Quantity
Target Structure-IDoc
IDoc
|-> Header
|-> Segment
Delivery_Order_No
Recv_Date
|-> Item
|-> Segment
Delivery_Order_No
Material_Num
Recv_Quantity.
The Logic is for every Order number an IDOC is generated.And if the Material num matches then the quantity should be added. and important note is that the material numbers are different for every order number. That means if a material number is 2 in the order number A. Then the material number can never be 2 in any of the order numbers.Here is the following with an example for the above scenario.
For example:-
we have
Source Structure- File
Order-no Date Mat_No Quantity
1 01/02/2011 A 10
1 01/02/2011 B 15
1 01/02/2011 A 10
2 01/02/2011 C 10
2 01/02/2011 C 10
3 01/02/2011 D 20
3 01/02/2011 D 10
3 01/02/2011 E 25
Target Structure-IDoc
Delivery_Order_No Recv_Date Material_Num Recv_Quantity
1 01/02/2011 A 20
1 01/02/2011 B 15
2 01/02/2011 C 20
3 01/02/2011 D 30
3 01/02/2011 E 25
So for this example total of 5-Idocs created. That means for this example if Order_No is 1 When the Mat_No is A the quantity gets added. For this Scenario 1 IDoc with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) is generated by adding the quantity field in the Target Side. Similarly if Order_No is 1 when the Mat_No is B then separate IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) in the Target Side. Similarly, if Order_No is 2 when the Mat_No is C, an IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) by adding the quantity field in the Target Side. ike wise the process goes on upto 3.Kindly do the needy..
Thanq very much in advance..
Edited by: Prashanth Bharadwaj on Oct 17, 2011 1:29 PMHi Prashanth,
Concatinate the two fields OrderNo and MaterialNo and follow the below logic which will resolve your problem.
concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext-->IDOC
concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext>splitByEachValue>subString(0,1)-->Delivery_Order_No
formatByExample>collapseContext>SplitByEachValue-->Recv_Date
FormatByExample:
input1:resulrOfSortByKey
input2:concatination>removecontext>sort-->SplitByValuChange
sortByKey:
input1:concatination-->removecontext
input2:date-->removecontext
concatinationOfOrderNo&MaterialNo>removecontext>sort>splitByValueChange>collapseContext>splitByEachValue>subString(1,1)-->Material_Num
formatByExample>sum>Recv_Quantity
FormatByExample:
input1:sortByKey
input2:concatination>removecontext>sort-->SplitByValueChange
SortByKey:
input1:concatination-->removecontext
input2:Quantity-->removeContext
Regards,
Priyanka. -
Need Query for empty partitions
I am having nearly 700 partitions for a table.Now i want to find out only the empty partitions.I need query for that.
Thankx..Not the most elegant solution, but it works:
declare
rc number;
str varchar2(200);
begin
for i in (select table_owner, table_name, partition_name from dba_tab_partitions) loop
str := 'select count(*) from ' || i.table_owner || '.' || i.table_name || ' partition (' || i.partition_name || ')';
execute immediate str into rc;
if rc = 0 then
dbms_output.put_line(i.table_owner || '.' || i.table_name);
end if;
end loop;
end; -
How to write query for this in TopLink ?
I am doing a simple search in jsp where the search will the based on the choices chosen by user.
I had given 3 check boxes for those choices.
The problem is, query will be based on the choice or choices chosed by the user.
How to write query for this in TopLink ?
Thanks in Advance..
JayaganeshTry below solution, it is NOT best solution but might work:
Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
INSERT INTO @Questions
VALUES (1, 'Comment'), (2, 'Score')
DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
INSERT INTO @Answers
VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,A.AnswerText
FROM
@Questions Q
INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
UNION
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,Null
FROM
@Questions Q
CROSS JOIN @Answers A
WHERE
NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
Output
AuthKey | QuestionID
| QuestionText
| AnswerText
101 | 1 | Comment | hi!!
101 | 2 | Score | 4
102 | 1 | Comment | excellent
102 | 2 | Score | 5
103 | 1 | Comment | NULL
103 | 2 | Score | 6
104 | 1 | Comment | NULL
104 | 2 | Score | 8
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
How should i write a query for this?
Hi i give the follwing query to implement the result,
IT will gives you the result of one country machines information like Total machines failed machines and success machines of their count
Countyr Name CountryCode Total Machines Failed Machines and Succes machines and their perentage
IT ITALY
1000 20
980 98%
like these i want to display the 16 countyr machines information all country information in one palce like table format
i will give you the query to the below here it is the combination of powershell code also used here with sql code.
Code as Country
Name as Country
And below i mentioned OU in bold every where i will put the country code according to the country
like OU=FR
Select
'FR' as 'Code',
'FRANCE' as 'Name',
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select COUNT(*) from ADComputersInfo where
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
(select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn in (select name0 from v_R_System)
(select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn not in (select name0 from v_R_System)
select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
select count(distinct(cn)) from ADComputersInfo where
(ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
or
ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
and cn not in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
So here i pass the County code and country name and OU=FR(assigned country code )
so hw we can all these 3 values in all the query can give me the r8 query for this . And i will get the all 16 country information
Ineed exact query hw we can implement..........................................
I might be excepting lot from our side guys...
Thanks !
AdvancedHi
Can you simple post sample data + desired result? Always state what version you are using..
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...
If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.
-
I need solution for this query
hi all,
could anyone please send me solution for this query these are the database tables am having
TABLE NAME :USERS
ATTRIBUTES
UNAME
PASSWORD
GROUPNAME
TABLE NAME:GROUPS
ATTRIBUTES
GROUPID
GROUPNAME
my requirement is that i need 2 acces the groupname of a particular user and the reamining groups to which i doesn't belong in A SINGLE QUERY
my result needs to be like this
Authorised group
consultant
UNAuthorised groups
sales
vender
recruiter
admin
if any body got the solution please sendhi All,
I have 3 tables 1)PREVILEGES (groupname, previleges(values y or n only))
2)GROUPS (groupid, groupname)
3) USERS (uname, groupname).
Here each user belongs to one group, each user hav a default previlege means example if user is consutant then he can access only consultant group. Means default previlege will be used. For default previleges, there is no record in Previleges table.
The Problem is that, I need to reterive the groupname from users which de doesn't belong as well as his previleges from previleges, If there is no values in previleges in the table it should return n. or value what is therey.
the different groups are
SALES,CONSULTANT,VENDER,RECRUTER,ADMIN
Maybe you are looking for
-
Dear All I have requirment My user want to know Stock avilability wtih Purchase Price. Is there any Possiblity Pl let me know regards
-
Hi guys I am working on an application in 3D i want to get the values x , y , z for mouse clicked i implemented a pick class package game_3d_31_03_08; import javax.vecmath.*; import javax.media.j3d.*; import com.sun.j3d.utils.picking.*;import com.sun
-
HT202663 Airport WiFi issues with united_club
Hello, I'm trying to figure out why I can't connect to "united_club" wifi properly. I get an IP address via DHCP, however, I can't ping the gateway nor the public DNS. If I switch over to my Verizon MiFi, I can successfully connect the the internet.
-
ITunes duplicates (I know youve already heard this before but hear me out)
Yes, my Itunes keep making duplicates, triplicates, etc of all my music. Heres the thing, I have gone over them MANY MANY times and there are NO duplicated files, no copies, nothing! This is REALLY making it hard to enjoy Itunes and my Ipod! These du
-
I goofed in transferring files I want to go back and restore to factory settings
I want to restore my computer to factory settings