473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to understand this query??

Expand|Select|Wrap|Line Numbers
  1. SELECT NVL(ManagerID,'Other') ManagerID, NVL(Manager,'Other') Manager, MAX(ManagerOpenACount) ManagerOpenACount, MAX(ManagerOpenUACount) ManagerOpenUACount, MAX(ManagerCloseCount) ManagerCloseCount, MAX(ManagerCount) ManagerCount, MAX(ManagerRejectCount) ManagerRejectCount, MAX(ManagerPendingCount) ManagerPendingCount, MAX(ManagerReopenCount) ManagerReopenCount, MAX(ManagerCPRCount) ManagerCPRCount, CONCAT('',ROUND(MAX(Pct),2)) Pct FROM " & _
  2.             "(SELECT U.Manager ManagerID, U.ManagerName Manager, COUNT(1) ManagerOpenACount, 0 ManagerOpenUACount, 0 ManagerCloseCount, 0 ManagerCount, 0 ManagerRejectCount, 0 ManagerPendingCount, 0 ManagerReopenCount, 0 ManagerCPRCount, 0 Pct FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Open' AND Who_Assign_Pension_Prod IS NOT NULL " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName " & _
  3.             "UNION " & _
  4.              "SELECT U.Manager, U.ManagerName, 0, COUNT(1), 0, 0, 0, 0, 0, 0, 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Open' AND Who_Assign_Pension_Prod IS NULL " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName " & _
  5.             "UNION " & _
  6.              "SELECT U.Manager, U.ManagerName, 0, 0, COUNT(1), 0, 0, 0, 0, 0, 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Closed' " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName  " & _
  7.             "UNION " & _
  8.              "SELECT U.Manager, U.ManagerName, 0, 0, 0, 0, COUNT(1), 0, 0, 0, 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Rejected' " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName  " & _
  9.             "UNION " & _
  10.              "SELECT U.Manager, U.ManagerName, 0, 0, 0, 0, 0, COUNT(1), 0, 0, 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Pending' " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName  " & _
  11.             "UNION " & _
  12.              "SELECT U.Manager, U.ManagerName, 0, 0, 0, 0, 0, 0, COUNT(1), 0, 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='Reopen' " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName  " & _
  13.             "UNION " & _
  14.              "SELECT U.Manager, U.ManagerName, 0, 0, 0, 0, 0, 0, 0, COUNT(1), 0 FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & " WHERE Status ='CPR' " & sSQLPriority & " GROUP BY U.Manager, U.ManagerName " & _
  15.             "UNION " & _
  16.              "SELECT U.Manager, U.ManagerName, 0, 0, 0, COUNT(1), 0, 0, 0, 0, 100*COUNT(1)/{0} FROM DirectEscalation I LEFT JOIN Users U ON (I.DirectUserName = U.UserName ) " & sSQLManagerOther & sSQLPriorityTotalCnt & " GROUP BY U.Manager, U.ManagerName " & _
  17.             ") a GROUP BY Manager, ManagerID
Jan 15 '08 #1
1 1153
debasisdas
8,127 Expert 4TB
To understand the query, you need to understand the basic of SQL .

Follow some good book for the purpose.
Jan 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SAN CAZIANO | last post by:
can you help me please because I can't understand why the code doesn't seems to function very well: in onkeypress it must verify if insert number or string value in the fiels, but it doesn't...
34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
2
by: Crimsonwingz | last post by:
Trying again for understanding and comprehension. Simple database. Name, birthday, age. Name and birthday are provided. From a form (yes, I need to do it this way), I would like to click a...
3
by: John Welch | last post by:
I'm developing my first multi-user application, and have been reading a lot about the basics of multi-user optimization (ADH vol 2, this newsgroup's archives, etc.). I've decided to go with a file...
5
by: dlevy | last post by:
I posted an inquiry on how to create a database to calculate the cost of an assembly. pietlinden was kind enough to take the time to spell it out for me..... however, I can't understand the...
19
by: so many sites so little time | last post by:
the table is head the colunm is called body <?php //show_site.php // This script retrieves blog entries from the database. // Address error handing. ini_set ('display_errors', 1);...
20
by: Wes Groleau | last post by:
I was doing update statements in SQL Server 2000. I have a table with over 16 million rows. It came from several hundred delimited text files, and two of the columns are file ID (int) and Line...
3
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user...
38
by: Jonathan Wood | last post by:
The following code raises the error "Specified cast is not valid." MembershipUser user = Membership.GetUser(userId); DataSet ds = DataLayer.ExecQueryData("SELECT * FROM mc_Clients WHERE...
1
by: NOTSomebody | last post by:
I am new to Perl and I have these codes but I am not quite understand the regular expression here. Can any1 please explain to me? $csv = "test.csv"; open(DAT, $csv) || die("Cannot Open File"); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.