What's the meaning of the SQL?
I found a sql like the following statement, I can't figure out why it uses "WHERE t2.id = t1.id + 0", has the "+0" have a special purpose? The result is the same when use "WHERE t2.id = t1.id".
SELECT count(*)
FROM t1
WHERE t1.status = 1
AND EXISTS (SELECT 1
FROM t2
WHERE t2.id = t1.id + 0
);
Hi,
This was a trick done in the old rule based optimiser (RBO) days to force the query not to use an index on a particular column. An index wont be used if an indexed column has a function on it and adding 0 to a number or appending null to a varchar was the easiest way to force this. These days with the cost based optimiser (CBO), the same still applies with a function on a column, but the optimiser is now smart enough to make its own mind up whether an index should be used or not.
My recommendation these days, provided you are using the CBO, is to remove these functions and let the optimiser make up its own mind. If in the rare case you still believe you know better than the optimiser, then you should use hints or stored outlines.
Andre
Similar Messages
-
What are the SQL server versions those are compatible with XI 3.0.
Hi All,
Please suggest,
what are the SQL server versions those are compatible with XI 3.0.
or with which SQL server versions XI 3.0 will interact using JDBC Adapter.Check in the [Product Availability Matrix |https://websmp201.sap-ag.de/~form/handler?_APP=00200682500000001303&_EVENT=DISP_NEW&00200682500000002804=01200314690900000192]in market place for more information on this
Thanks
SaNv... -
What is the SQL Standard for passing back a 0 in an Amount Field
So I have an Amount Column in my database. What is the best way and the SQL Standard to pass back a 0 if it is a <NULL>? With a COALESCE statement?
Thanks for your review and am hopeful for a reply.This is UNBELIEVEABLE! I got rid of my TextBox13 all together...Deleted it to start from scratch. And it is still erroring on TextBox13!!! I even checked the Properties List and there is no TextBox13. What in God's name is going on here?!?!?
Am I missing something???
Hi ITBobbyP,
As to this issue, I find that this is a known issue which you can see on the link below:
http://connect.microsoft.com/SQLServer/feedback/details/649210/bids-sql-2008-r2-warnings-not-clearing
According to the Feedback, we can workaround this known issue by Re-open the project. And if Warning was in fact resolved, it will no longer show on the Business Intelligence Development Studio (BIDS) "Error List".
As to your former issue, please refer to the expression post by
Jingyang Li.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
What is the sql statement for doing this?
Hi,
I am currently doing a simple search engine that allows a user to key in a filename and display all the files' name close to keyed filename(the first two letters are the same).What is the proper sql statement to select from Document according to DocumentType and the first two letters of the filename? Am i doing it the right way? I am currently use Access 2002, dunno if it will affects me.Thanks in advance
[What i did]
String filename="doc,txt"
SELECT DocumentType from Rule where UserType='1' and Action='Search';
DocumentType=1,5,9,13,17,21,25,29,33,37,41,45 // This is all the document Type the user can see.
Next i used StringTokenizer break the DocumentType.
DocumentType[0]=1;
DocumentType[0]=5;
SELECT * from Document where DocumentType and Name <<< I want to select from Document according to DocumentType and the first two letters of the filenameOne more try - from what I can follow?
If I assume you have a table named for example "UserRules"
which has fields UserID,UserType,UserAction
and has records like this that controls the document types
a user is allowed to see
UserID UserType Action
TOM 1 Search
BILL 7 Search
ROY 2 Search
And if I assume you have a table named for example "AllowedUserDocumentTypes"
which has fields UserType,DocumentTypes
and has records like this that controls the document types
a user is allowed to see
UserType DocumentTypes
1 1,3,4,5,6,19
2 7,9,12,18
3 1,19,33,27
And you have the document table which has
fields are DocNo,Name,Title,Date,Filename,DocumentType
and it has records like this
DocNo Name Title Date Filename DocumentType
12345 BILL Cars CarTypes 18
12346 ROY Trucks TruckTypes 2
12347 TOM Toys ToyTypes 17
12345 JACK Car Colors CarColors 19
12345 TOM Car Shapes CarShapes 7
Then the select statement
Select DocumentTypes from AllowedUserDocumentTypes
join UserRules where UserRules.UserType = AllowedUserDocumentTypes.UserType
and UserRules.UserID = 'ROY' and UserRules.Action = 'Search';
will return 7,9,12,18
If the DocumentType field is numeric and the user entered "CarCrap" the
select statement would have to look like this
SELECT * from Document
where left(Filename,2) = 'Ca' and DocumentType in (7,9,12,18);
If the DocumentType field is say varchar
select statement would have to look like this
SELECT * from Document
where left(Filename,2) = 'Ca' and DocumentType in ('7','9','12','18');
You will have to build these select statements related to the user.
Note you should also allow for upper and lower case differences. I
would suggest you convert the user entry into uppercase and do a select
like below
SELECT * from Document
where Ucase(left(Filename,2)) = 'CA' and DocumentType in (7,9,12,18);
This is all written from memory, not tested and I have not done this
in several years.
I was showing approximately how to build the statements before.
rykk -
What is the sql command for SELECT with OR condition
Hi
What is the correct sql command for doing select with or condition??
SELECT * from TempData
WHERE port = '123'
OR serialnumber = '555'
So if there is a port = 123 or if there is a serialnumber = 555, I will get a successful select.
Thanks for helping a newbie!!Hi
What is the correct sql command for doing select with
or condition??
SELECT * from TempData
WHERE port = '123'
OR serialnumber = '555'
So if there is a port = 123 or if there is a
serialnumber = 555, I will get a successful select.
Thanks for helping a newbie!!Make sure you bracket your OR conditions
eg
SELECT * from TempData
WHERE column = 'VALUE'
and port = '123'
OR serialnumber = '555'
is read as
SELECT * from TempData
WHERE (column = 'VALUE'
and port = '123' )
OR serialnumber = '555'
which is not the same as
SELECT * from TempData
WHERE column = 'VALUE'
and ( port = '123'
OR serialnumber = '555' ) -
What is the SQL ROWNUM equivalent in HANA SQL script
Hi,
Could any one let me know what is the ROWNUM equivalent in HANA? Thanks for the help.
Thanks,
JyothirmayiHi Jyothirmayi,
ROW_NUMBER() OVER (ORDER BY <FIELD LIST>) is the function to generate row numbers.
ORDER BY clause is mandatory to generate row numbers in HANA.
Regards,
Chandra. -
What is the sql query for the real time reports Resource Stats?
Does anyone know what the query is that the real time report tool uses for the Resource Stats page? Trying to develop a custom report that displays similar information that is updated regularly.
Hi,
009 wrote:
Hi Frank,
Just wanted your opinion on the above given SQLI'm not sure I understand it.
I added some more formatting to help me read it:
SELECT A
, CASE WHEN LAG(A,1) OVER (ORDER BY A) IS NULL
OR A=LAG(A,1) OVER (ORDER BY A)
THEN LAG(B,1) OVER (ORDER BY A)
END B_LAG
, B
FROM (
SELECT A, B
FROM
SELECT '1'A,'Apple' B FROM DUAL UNION ALL
SELECT '1'A,'cat'B FROM DUAL UNION ALL
SELECT '2'A,'bat'B FROM DUAL UNION ALL
SELECT '3'A,'rat'B FROM DUAL UNION ALL
SELECT '2'A,'yellow'B FROM DUAL UNION ALL
SELECT '1'A,'pin'B FROM DUAL
CONNECT BY PRIOR A=B
ORDER BY A
);What is the purpose of the CONNECT BY in what you have so far?
Is the idea that you will add another CONNECT BY query, using
CONNECT BY b_lag = PRIOR b?
Do you think that will be better than using ROW_NUMBER?
Will it work if (a, b) is not unique? -
What is the SQL syntax to do Where = "Parameter" ?
I have a menu list linkied to a query. I want the user to select one from the list and pass it to the data source query to return results.
Whats the syntax in the data source SQL to add this in?
My Parameter is called Param1 and I tried:
where xxxx = param1Just a side note, a null parameter in BIP is != null. You have to coalesce the parameter to null. I had to ask a while back to find this little piece of info out.
-
What is the sql query to know the database name having known table name?
when i am running the following query....error coming
select * from information_schema.tables where table_name = 'articles'
Error starting at line 1 in command:
select * from information_schema.tables where table_name = 'articles'
Error at Command Line:1 Column:33
Error report:
SQL Error: ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
i am running the above query in SQLDeveloper tool against ORACLE database
plz give alternate solution.Hi,
select * from information_schema.tables where table_name = 'articles'You are trying query view ( information_schema.tables ) from MSSQL on ORACLE??!!
Each RDBMS have your own data dictionary... you must check documention of ORACLE to query the properly data dictionary.
Try it:
select * from users_tables where table_name = 'articles'
or
select * from all_tables where table_name = 'articles'
or
select * from dba_tables where table_name = 'articles'http://docs.oracle.com/cd/E11882_01/server.112/e25494/general011.htm#ADMIN11564
Regards,
Levi Pereira -
What is the SQL command to list all tables in a access database(mdb)
hi everyone
can anybody tell me
how to retreive and display total number of tables or total table name
in a particular database in jsp page
thank you .I dont think you can count the number of tables, maybe you mean number of rows in a table..If so, you need to make a method in your class and query to your database. Something like this:
String count = "SELECT COUNT(*) FROM EMPLOYEES";
Statement stmt = con.createStatement();
rs = stmt.executeQuery(count);
int rsInt = rs.getInt(1);The value of rsInt will result to the number of your tables. -
What is the sql query for this
table Employee
EmpId
Name
MonthlySalary
DateofJoining
Suggest a sql server query to find out the employee details whose having salary greater than their yers of experiance
nravhadHi ,
As this seems to be a kind of lab exercise question for learning purpose , i am giving you the pseudo code which will help to solve this problem and learn.
select <the requeired columns> from employee table.
where Find the no of years between dateofjoining and current date using DATEDIFF function< monthly salary
if this is not a lab exercise problem for learning purpose , please forgive my ignorance.
Best Regards Sorna -
What is the sql waiting for 9000+ sec ??
http://download.oracle.com/docs/cd/B19
306_01/server.102/b14237/dynviews_2094.htm#REFRN30229
Edited by: S2K on Dec 23, 2009 12:09 PM
Edited by: S2K on Dec 23, 2009 12:38 PMskvaish1 wrote:
Hi,
Sorry I inferred as Simple view. You may increase the PGA to 500M or 1024M which may help you on HASH JOINS but it will be helpful on next session. Existing session will not get affected. Also you have to work on your query to reduce so many FULL table scans. I an not sure if you have updated statistics on the involved tables.
He's spent 9,946 seconds on the CPU without waiting - so sizing of the PGA to avoid spilling workareas to disk is not his problem and messing about with the PGA_AGGREGATE_TARGET is unlikely to help.
The most obvious guess is that the aggregate subquery with full tablescan indicated by the last three lines and the FILTER at line two (id 1) really is happening the 266 thousand times indicated by the ROWS in line 3 (id 2). (And it's happening in memory.)
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
"Science is more than a body of knowledge; it is a way of thinking"
Carl Sagan -
Why's the SQL format different for the same report on different PCs?
I have 2 PCs running the same version of Crystal Reports (11.0.0.1994) using an identically configured system DSN with the exact same driver. When I view the SQL that CR is using on PC 1, part of it looks like this:
" FROM {oj (("PUB"."LOQEstimate" "LOQEstimate1" LEFT OUTER JOIN "PUB"."LOQComponent" "LOQComponent1" ON ("LOQEstimate1"."Estimate-ID"="LOQComponent1"."Estimate-ID") AND"
On PC 2 it looks like this:
"FROM "PUB"."LOQEstimate" "LOQEstimate1", "PUB"."LOQComponent" "LOQComponent1", "PUB"."CustContact" "CustContact1", "PUB"."LOQSegment" "LOQSegment1"
WHERE"
It's the exact same report. Can someone tell me why the SQL is different?
TIA for the help.Thanks for the reply, Patrick. Here are the answers you requested:
1. Verify you are indeed using the same driver, and they are of the same version
The driver on both PCs is the Progress OpenEdge 10.1A driver. The file is pgoe1021.dll, version 05.10.0037.
2. Verify if you have the same database client install on both computer.
Both use prowin32.exe, v10.1.1.1326
If everything is the same, then it might be a registry key, and in this case, can you provide the following information:
1. What database are you connecting to? ( Oracle, DB2, ... )
Progress OpenEdge 10 RDMS (/community [original link is broken])
2. What is the version of the database?
10.1A
3. What is the version of the database client?
v10.1.1.1326
4. How are you connecting to your database? ( Native, ODBC, OLEDB,... )
ODBC
5. If you are connecting via ODBC, what is the name of the driver used and it's version?
The driver is the Progress OpenEdge 10.1A driver. The file is pgoe1021.dll, version 05.10.0037.
6. What is the SQL query syntax do you prefer? ( PC 1, or the one generated on PC 2 )
The SQL generated on PC1 doesn't return any records. The SQL generated on PC2 does. Records are preferable ;o) -
How do i see the sql statements that are run ?
i want to see (in a log file) what are the sql statements that oracle had ran.
how do i do it ? what configurations should i do ? how ?
please help ... thanksCurrent SQL statements are viewed in dynamic tables:
SELECT SCHEMANAME, SQL_ADDRESS, SQL_TEXT, last_call_et
FROM V$SESSION, V$SQLAREA
WHERE V$SESSION.SQL_ADDRESS=V$SQLAREA.ADDRESS
A historical log of all SQL statements is recorded in Oracle Archived Logs, and can be viewed using the Oracle Logminer approach. This process requires your database to be in ARCHIVELOG mode, and that Logminer be configured to read the archived logs. -
Where and how do I get the SQL Query used by the Microsoft Generic Report Library - Alerts?
Background:
I'm tasked with the following: I need to create a new Report and the SQL
The two canned reports that I can pattern after are: Microsoft Generic Report Library
- Alerts (there is also an alert detail report that can be chosen within the alert report that we may want to use instead)
- Most Common Alerts
I'm trying to do this:
Add another parameter to search on customfield3.
It should be able to report on all alerts that were assigned to the specific team for the time period along with the top 10 (most common alerts) assigned to the team for the time period.
Choose as the objects (group) all servers, but Imay need to adjust the report to just look at all alerts without having to provide objects or a group
The struggle I'm having is: I know SQL. I know how to create an RDL file.
But Where are the RDL files for the canned reports so I can modify the canned RDL and modify its SQL and forms?
What is the SQL/ where can I find the SQL used for the Generic Report Library -> AlertsEasy but you need to extract it from Microsoft Generic Report Pack.
So.. the procedure is as follows:
1) You export and unseal Management Pack from your SCOM using
Boris's OpsgMgr tools (MPViewer
2.3.3)
2) Ok you've got unsealed xml, now the tricky part, use
MpElementsExtract tool, example of usage:
MPElementsExtract.exe <MP.xml> /ex /destination:<destination>
That you way you get several folders out of mp:
DWScripts, DWSubScripts, LinkedReports, ReportResources, Reports
Take a look into content of first 2, there will be pure sql scripts, and rdl's are in Reports folder :)
Other way is to just use SQL profiler and catch SQL query while generating report.
--- Jeff (Netwrix) -
What does the usage of CURSOR word mean in an SQL statement?
Hey folks,
Please check out the following query and do please explain me what does the usage of CURSOR keyword in an SQL statement mean.
select deptno,cursor(select ename from emp a where a.deptno=b.deptno) from dept b;
well, the output was like this,
DEPTNO CURSOR(SELECTENAMEFR
10 CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
ENAME
CLARK
KING
20 CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
ENAME
SMITH
JONES
SCOTT
ADAMS
FORD
30 CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
ENAME
ALLEN
WARD
MARTIN
BLAKE
TURNER
JAMES
6 rows selected.
40 CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
no rows selected
Your favour'll be deeply appreciated.
Cheers,
PCZThis returns a non-square result set. Each row of the result is a deptno and then a result set of the enames in that deptno.
This can be useful when you need to send a lot of data to a client application in a single query that would otherwise contain a lot of redundancy. It tends to be a relatively unusual construct (I've only found one situation where it was appropriate in my career) and requires some relatively sophisticated understanding on both the database and client sides.
Justin
Maybe you are looking for
-
[SOLVED] Problems opening folders with UTF-8 encoded characters
Hello everyone, I'm having an issue when I acess folders in all my programs ( except Dolphin File Manager). Every time I open the folder navigation window in my programs, folders with UTF-8 encoded characters ( such as "ç", "á ", "ó", "í", etc ) are
-
CP5: connecting permanently text boxes by lines
When I create several text boxes and want to connect them like a diagram with lines (see below): how should I draw the lines so that they would not loose the entry points of both related tex boxes when a text box is moved on the slide? With my first
-
bought my mac pro for 1099. to repair it cost 754, is it worth repairng?, bought my mac pro for 1099. to repair it cost 754, is it worth repairng
-
Connecting XP Laptop to Time Capsule
I have a time capsule that I can easily use with my XP laptop and of course my MacBook. My wife has a laptop running XP that is asking for a Network Key. It seems to want the Hexadecimal key and not that passphrase the the other machines connected wi
-
Guest Network in Airport Utility
I have just been reconfiguring my wireless network. I noticed it's still broadcasting a guest network, yet when I try to configure it in airport utility I can no longer find the guest network settings. I'm sure they used to be in the Wireless section