Tricky sql queries for interview preparation
Hi,
I need tricky sql queries as preparation for interview.
pls let me know if anybody has the such queries website address.
or
if you have materials pls mail me on
[email protected]
thnx
NKU wrote:
Great Work Kamran....:-)
Regards,
Navneet;)
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]
Similar Messages
-
Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
somewhere that there should be a compact database option. but I do not see it.
What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
Thank you for your help..
diana4Hello,
With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
You can use the free SQL CE Toolbax instead; see
http://sqlcetoolbox.codeplex.com/
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Sql queries for retrieving setups data for functional modules
Hi,
Can anyone give me the sql queries for retrieving setups data for functional modules (GL, AP, AR, FA, and CM) from Database.Hi,
Can anyone give me the sql queries for retrieving setups data for functional modules (GL, AP, AR, FA, and CM) from Database. -
SQL queries for finding values in 4 different tables
I need to have certain queries to find specific data in this table, this is just an example table, but I will use the same ideas for my actual website and database.
customers (customerID: integer, fName: string, lName: string)
items (itemID: integer, description: string, price: float)
orders (orderID: integer, itemID: integer, aID: integer, customerID: integer, date: date)
addresses (aID: integer, housenum: integer, streetName: string, town:string, state: string, zip:integer)
Values I need to find are
List the town, first name, and last name of any customer who has shipped an item to the same town as another customer.
Return the average amount of money each customer spent in March of 2013. (Note that the answer will be a single number
List the first and last names of all customers who have had the same item shipped to at least two different addresses.
List the top two states that have generated the most total revenue and the revenue they generated
I did try a few different queries, for #3 I tried
SELECT customers.fName,
customers.lName,
COUNT(orders.itemID) AS `total items with diff address >= 2`
FROM customers
JOIN (SELECT customerID,itemID,
COUNT(DISTINCT aID) AS diff_address
FROM orders
GROUP BY orders.itemID
HAVING diff_address >= 2
) AS orders
ON orders.customerID = customers.customerID
but I only got 1 result, and I do not think thats correct.
Thanks for the help and I appreciate you taking the time to help meWhy not post the sample data + desired result? Always state what version you are using.
SELECT lname,A.aID,COUNT(*) cnt FROM customers C JOIN orders O ON c.Customerid=O.Customerid
JOIN address A ON A.aID=O.aID
GROUP BY lname,aID
Sorry cannot test it right now...
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 -
Need Guidance for interview preparations
Hello,
I am preparing for interviews. I am revising ABAP and webdynpro. can you suggest me which topics are more important from interview point?Hi,
This is not right place to search interview q's.
Please do search in GOOGLE you find lots of material..
http://www.google.co.in/search?hl=en&source=hp&q=webdynproabapinterviewquestions&meta=&aq=1s&aqi=g-s7g2g-m1&aql=&oq=webdynpro+abap
Cheers,
Kris. -
Hi Friends,
I Have a view named - item_sales with 4 column
Item code
Item name
Transaction_YYYYMM (Date stored in YYYYMM format )
QTY_RECEIVED
QTY_SOLD
Sample data is
ITEM_CODE ITEM NAME TRANSACTION_YYYMM QTY_RECD QTY_SOLD
AX TSHIRT 201307 3000 2000
AX TSHIRT 201308 2000 500
AX TSHIRT 201309 1000 3000
CX XLSHIRT 201307 3000 2000
CX XLSHIRT 201308 3000 2500
CX XLSHIRT 201309 3000 2500
EVERY MONTH END I WILL RUN THIS QUERY TO FIND OUT THE BELOW DETAILS
1. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD ( FOR CURRENT MONTH - EXAMPLE SEP )
2. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD (FOR CURRENT YEAR EXAMPLE FROM JAN TO SEP )
OUTPUT FOR SEPTEMBER MONTH LOOK LIKE THIS
SEP-MONTH JAN TO SEP
ITEM_CODE ITEM_NAME QTY_RECEIVED QTY_SOLD QTY_RECEIVED QTY_SOLD
AX TSHIRT 1000 3000 6000 5500
CX XLSHIRT 3000 2000 9000 7000
Pls advise me how to write queries for this
RdkJust FYI, you *can* edit your own posts, you know
Rdk wrote:
Transaction_YYYYMM (Date stored in YYYYMM format )
First "problem". Don't store dates as string. Store them as dates. It will save you so much headache don't the road you won't believe it.
True, this is a view, so maybe not as critical - assuming the underlying *DATA* is actually a date.
1. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD ( FOR CURRENT MONTH - EXAMPLE SEP )
2. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD (FOR CURRENT YEAR EXAMPLE FROM JAN TO SEP )
So yeah, based on these requirements, I'd recommend you make that column a DATE, not a string. Dates are easier to parse for date-related logic - such as month by month as you need here.
Using that, here's one way to do it:
with w_data as (
select 'AX' item_code, 'TSHIRT ' item_name, to_date('20130701','yyyymmdd') trans_dt, 3000 qty_recd, 2000 qty_sold from dual union all
select 'AX' , 'TSHIRT ' , to_date('20130801','yyyymmdd') , 2000 , 500 from dual union all
select 'AX' , 'TSHIRT ' , to_date('20130901','yyyymmdd') , 1000 , 3000 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130701','yyyymmdd') , 3000 , 2000 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130801','yyyymmdd') , 3000 , 2500 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130901','yyyymmdd') , 3000 , 2500 from dual
w_base as (
select item_code, item_name, trans_dt, qty_recd, qty_sold,
sum(qty_recd) over (partition by item_code, trunc(trans_dt, 'MM')) mm_recd,
sum(qty_sold) over (partition by item_code, trunc(trans_dt, 'MM')) mm_sold,
sum(qty_recd) over (partition by item_code, trunc(trans_dt, 'YY')) yy_recd,
sum(qty_sold) over (partition by item_code, trunc(trans_dt, 'YY')) yy_sold,
row_number() over (partition by item_code order by trans_dt desc) rnum
from w_data d
Select item_code, item_name, mm_recd, mm_sold, yy_recd, yy_sold
from w_base
where rnum = 1
IT ITEM_NA MM_RECD MM_SOLD YY_RECD YY_SOLD
AX TSHIRT 1000 3000 6000 5500
CX XLSHIRT 3000 2500 9000 7000 -
Hello All,
Can any body give me the total SQL queries which will be used in SAP.
Thanks&Regards,
Praveen KondabalaHi,
If you do need that kind of information, then it is easier that you do not use any.
> Like Oracle DBA
you only need to read the documentation about
1) brtools
2) dbacockpit (I assume you have a fairly recent SAP version)
you can find the information about this two "things" in
SAP on Oracle -
Sql queries for this database schema
1) Patient—PatientID, Name, DOB
2) Doctor—DoctorID, Name, MedLicenseNumber, Phone
3) Medication—MedicationID, BrandName, GenericName
4) Prescription—PrescriptionID, Date, PatientID, PrescriberID, MedicationID
Specify the SQL queries to retrieve:
a) The prescription information along with patient name, DOB, medication brand name, and prescribing doctor name sorted by most recent date.
b) The most prescribed generic medication nameLooks like assignment question to me
a, seems to be a case of straight forward join among all the involved tables on common fields. Suggest you learn about joins and try it out yourself.
see below link
http://www.w3schools.com/sql/sql_join.asp
b, Have a look at GROUP BY. you need to apply group by and take medicine name which repeats maximum (ie largest count value)
see
http://www.w3schools.com/sql/sql_groupby.asp
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
SQL Queries for open sales orders with no invoice.
Hello all!
Is there a way to make a query to find out if there are any uninvoiced sales orders older than 5 days? I am having difficulty figuring out how the invoice is linked to the sales order.
I am more familiar with excel than SQL but I'm guessing it will be similar to the following:
SELECT * FROM ORDR WHERE today's date - posting date>5 AND (not sure what to check here for the invoice having been created)
**Note: my syntax is of course not exactly correct, this is just to give you an idea of what I'm looking for
Has anyone had to do this before or know how it would be done? It would be very useful for me.
Thanks!
MikeHi Mike
The document link is built on row level so the RDR1 should be used instead of ORDR to server your propose.
You could use this query to get all the lines do not link to a invoice.
*targettype 13 refers to target document invoice
select t0.docentry,t0.docdate,t0.linenum,t0.itemcode,t0.quantity,t0.price,t0.linetotal
from rdr1 t0 join ordr t1 on t0.docentry= t1.docentry
where t0.trgetentry is null and t0.DocDate < dateadd("d",-5, getdate()) and t1.docstatus = 'O'
or just use this query instead to find those lines do not link to any document
select t0.docentry,t0.docdate,t0.linenum,t0.itemcode,t0.quantity,t0.price,t0.linetotal
from rdr1 t0 join ordr t1 on t0.docentry= t1.docentry
where t0.targettype !='13' and t0.DocDate < dateadd("d",-5, getdate()) and t1.docstatus = 'O'
Please modify the code according to your needs.
Regards,
Syn Qin
SAP Business One Forums Team
Edited by: Syn Qin on Aug 11, 2008 5:20 AM -
Data Not Applied (logs)
Data Not Received (logs)
Data Guard Status
We are unable to add above metrices to rules in GC R2. So we are are planning to monitor them as UDM. Anybody can provide us with queries that would be needed to have metrices as UDMS.
Help will be really aapreciated.
TIA
SaayaI went down that path. It is a dead end if you are thinking of using SQL UDM. SQL UDM require database credentials. In the UDM screen there is no connect as sysdba option. You can only specify username and password. Standby databases are in recovery mode. You will be not be able to connect to them without sysdba or sysoper.
You could setup up a host UDM. It is quite a lot of effort to do that. -
Links with sql queries to practice
Hi all,
Can someone give me the links with sql queries for practice to preparing for OCP
Thanks
Shekar.Hi,
Can u repost?? as its very difficult to understand ur problem.
Vasu Natari. -
Hello,
I have quite strange question related to my research.
Probabley within Oracle DB there is some dynamic library which is parsing SQL queries,
for example.
SELECT * FROM schema.table which is able to extract informations from SQL listed above that we want to display all columns from selected table.
When this construction is valid ( SQL standard ) the next step is verification the object existence in DB. It means
that there are two separated actions which are analyzing queries.
I need only first part of that process, which will give me informations about all object used in SQL query
is it possible to accomodate that internal parser witin stand alone middleware like Weblogic Event Server ?
I can do it with regular expression patters, but it's not going to be fast and effective for subqueries and all advanced
constructions for DHW like MODEL, etc.
Thank You,
R.>
http://search.cpan.org/~rehsack/SQL-Statement-1.23/lib/SQL/Statement.pm
BUGS AND LIMITATIONS ^
* currently we treat NULL and '' as the same - eventually fix
* No nested C-style comments allowed as SQL99 says
>
That's the reason why I want to use dedicated for 11g EE library ;-)
Thanks for quick reply -
Handling DST in SQL Query for UCCX Custom Report
We wrote all custom reports for one of the call centers using our UCCX deployment. One problem we see we will hit in the future is DST. We suggested they use UTC but they wanted to see the call data based off of EST timezone. Right now we are okay because we use -5 to get the correct data but come March we are wondering how to address the issue. What options do we have? How are other people handling DST with the SQL queries for custom reporting? I see that the HR client will determine this based off of the local computer time then gives you the option to use UTC. We have all of our queries in an Excel document that the customer just needs to open and select Refresh All to update their data.
Thanks"case-when" statements are evaluated in order.
so you must do something like this:
SELECT
CASE WHEN <is not number>THEN 'N'
CASE WHEN <is greater than 0>THEN 'Y'
Now "<is greater than 0>" will always have number for input, can't get "not number" error there.
See this thread:
Re: regular expression: integer is between N..M
Edited by: CharlesRoos on May 27, 2010 5:03 AM -
Want to practice SQL queries, do I need to download SQL editor
Hi All,
I have a doubt..
I want to practice SQL queries. for this, do I need to download SQL editor and Intall or If I download any Oracle version, does it will have SQL editor? please anyone answer my question.I'm not sure how is it related to Peoplesoft, but if you installed an Oracle client on your client machine, then you have SQL*Plus or SQL Developer.
Nicolas. -
I'm trying to do two fairly tricky SQL statements for a class, and been trying for a while and have gotten stuck.
The first one is, "Find Courses where more than half the students got an A"
I've basically been trying to use not exist statements to set it up and then compared the count(sid)/2 > count(sid) query of all A's and am just not getting decent results from it.
The REALLY tricky one is "Find the pairs of students who took exactly the same set of courses"
I can get a cross product from all students with something like this
SELECT s1.sname, s2.sname
FROM lab6_student s1, lab6_student s2
WHERE s1.sname > s2.sname
but after that I can't seem to get it to work properly at all.
Thanks for any pointers/advice!1.
SQL> WITH T
2 AS (SELECT 'mathematics' course_name, 'john' student_name, 'A' grade FROM DUAL
3 UNION ALL
4 SELECT 'mathematics' course_name, 'john1' student_name, 'A' grade FROM DUAL
5 UNION ALL
6 SELECT 'mathematics' course_name, 'john2' student_name, 'A' grade FROM DUAL
7 UNION ALL
8 SELECT 'mathematics' course_name, 'john3' student_name, 'B' grade FROM DUAL
9 UNION ALL
10 SELECT 'physics' course_name, 'john' student_name, 'A' grade FROM DUAL
11 UNION ALL
12 SELECT 'physics' course_name, 'john1' student_name, 'B' grade FROM DUAL
13 UNION ALL
14 SELECT 'physics' course_name, 'john2' student_name, 'B' grade FROM DUAL
15 UNION ALL
16 SELECT 'physics' course_name, 'john3' student_name, 'B' grade FROM DUAL)
17 SELECT *
18 FROM T;
COURSE_NAME STUDE G
mathematics john A
mathematics john1 A
mathematics john2 A
mathematics john3 B
physics john A
physics john1 B
physics john2 B
physics john3 B
8 rows selected.
SQL> WITH T
2 AS (SELECT 'mathematics' course_name, 'john' student_name, 'A' grade FROM DUAL
3 UNION ALL
4 SELECT 'mathematics' course_name, 'john1' student_name, 'A' grade FROM DUAL
5 UNION ALL
6 SELECT 'mathematics' course_name, 'john2' student_name, 'A' grade FROM DUAL
7 UNION ALL
8 SELECT 'mathematics' course_name, 'john3' student_name, 'B' grade FROM DUAL
9 UNION ALL
10 SELECT 'physics' course_name, 'john' student_name, 'A' grade FROM DUAL
11 UNION ALL
12 SELECT 'physics' course_name, 'john1' student_name, 'B' grade FROM DUAL
13 UNION ALL
14 SELECT 'physics' course_name, 'john2' student_name, 'B' grade FROM DUAL
15 UNION ALL
16 SELECT 'physics' course_name, 'john3' student_name, 'B' grade FROM DUAL)
17 SELECT *
18 FROM (SELECT course_name, COUNT (*) total_cnt, SUM (CASE WHEN grade = 'A' THEN 1 ELSE 0 END) grade_cnt
19 FROM T
20 GROUP BY course_name)
21 WHERE grade_cnt > total_cnt / 2;
COURSE_NAME TOTAL_CNT GRADE_CNT
mathematics 4 3
SQL>
2.
SQL> WITH T
2 AS (SELECT '1' course_id, 'john' student_name FROM DUAL
3 UNION ALL
4 SELECT '2' course_id, 'john' student_name FROM DUAL
5 UNION ALL
6 SELECT '1' course_id, 'peter' student_name FROM DUAL
7 UNION ALL
8 SELECT '2' course_id, 'peter' student_name FROM DUAL
9 UNION ALL
10 SELECT '3' course_id, 'king' student_name FROM DUAL
11 UNION ALL
12 SELECT '4' course_id, 'king' student_name FROM DUAL)
13 SELECT *
14 FROM t;
C STUDE
1 john
2 john
1 peter
2 peter
3 king
4 king
6 rows selected.
SQL> WITH T
2 AS (SELECT '1' course_id, 'john' student_name FROM DUAL
3 UNION ALL
4 SELECT '2' course_id, 'john' student_name FROM DUAL
5 UNION ALL
6 SELECT '1' course_id, 'peter' student_name FROM DUAL
7 UNION ALL
8 SELECT '2' course_id, 'peter' student_name FROM DUAL
9 UNION ALL
10 SELECT '3' course_id, 'king' student_name FROM DUAL
11 UNION ALL
12 SELECT '4' course_id, 'king' student_name FROM DUAL),
13 r
14 AS (SELECT student_name, SUM (POWER ( 2, course_id)) val
15 FROM T
16 GROUP BY student_name)
17 SELECT DISTINCT student_name NAME
18 FROM r
19 WHERE EXISTS
20 (SELECT 'x'
21 FROM r r1
22 WHERE r1.val = r.val
23 GROUP BY val
24 HAVING COUNT (*) > 1);
NAME
john
peterEdited by: G. on Feb 24, 2011 2:09 PM
Maybe you are looking for
-
Downloading zip files - problem
I have a program which is supposed to allow download of a zip file to the users PC and then write a record to a database showing that the user has downloaded the file. When I try and read the file I have downloaded I get an error message which says t
-
Selection Screen seems not to be transported, all transport log OK
hi, our ABAP build own Z-program in SDV. After that, they transport the program to QA client using STMS and also to Production Client using the same method. All the transport log is error-free. The problem occurs in PRD, when all selection screen dec
-
Enterprise DQ - hardware and sizing question
Hi, we are considering implementing Oracle Enterprise Data Quality (all components) and would like to know the hardware (memory, number of CPU's, etc.) sizing parameters/requirements for this software. Obviously, data volumes are a key factor. I'm
-
There are two features Apple's Terminal lacks that drive me crazy, tabs and the ability to define a list of characters considered part of a word when double clicking. iTerm can do both of these things and I really like it, but there are some serious
-
When using mirror on AppleTV instead of mirroring my iPod I get a random picture from library. How do you fix this?