B reports to A
C reports to A
D reports to A
E reports to B
F reports to B
and so on......
So, when A logins he should be able to see B,C,D(who are reporting to A) and also E,F(who are actually reporting to B and not directly to A)Please help to write such sql query.
* 100 AS PERCENTAGE FROM support.SRFILE INNER JOIN BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = SRFILE.SRONUMBER WHERE (BSFLBWF_1.Closex IS NULL) AND (BSFLBWF_1.DedTypex = 'School' OR BSFLBWF_1.DedTypex = 'LAN-MLE') UNION ALL
The rest of the query continues as the above albeit selecting the same data from different tables and works fine.
The issue I have is that I want to Select some more data (another SELECT query) but with a different Where clause e.g. WHERE (BSFLBWF_1.KPIx NOT LIKE 'KPI%' OR BSFLBWF_1.KPIx NOT LIKE 'Proactive%') AND (BSFLBWF_1.Availabilityx LIKE '')
The problem is that this WHERE clause returns data which the above in bold has null values for (and thus doesnt work). Im still selecting the same data its just the WHERE Clause has changed. Is it possible to run such a query? If so, can it be done via a sub query?
I need to write a query (SQL Server) which gives me data according to the tags say if I want bookIds where tagid =9 it should return bookid 113421 and 113422 as it exists in both the books, but If I ask data for tags 9 and 10 it should return only book 113421 as that is the only book where both the tags are present.
im doing an update in web page by pressing a button. At the start some of the update was from a trigger, but i decided to put the hole update statement in the web page as an updatecommand in VB. this is the error Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.The statement has been terminated.and this is the code.
[Code]....
the error is in the updatecommand. And i dont know what is it.
i have a table for customer forecast which contains customer, week number and quantit as columns. now i need to write query and list the week as column for each customer and each cell should have a quantity. how to write query for this using pivot logic. i dont want to use cursor.
So,my question is that why we basically use @ before the sql query.If I don't use @ before that then it again work fine (does not give any error), then what is need of using "@"?
select NotificationID, (select u.UserName from aspnet_Users u, notifications n where u.UserId = n.FromID) as 'UserName', [Message], DateCreated, TypeID from Notifications n, aspnet_Users u
I always received an error of: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I have a SELECT query which grabs data from two different tables however when I run the query the CurrentCallOwner often pulls up the same name twice albeit with a different SLAFailed value. What I am trying to do is bind those two values into one. I thought that running a subquery and using a count would solve this however I all receive are a bunch ones. Do you know how I could bind those values into a single value (i.e. add them up?)
SELECT CurrentCallOwnerx, SLAFailed, COUNT(CurrentCallOwnerx) AS Expr1 FROM (SELECT BSFLBWF_1.CurrentCallOwnerx, COUNT(BSFLBWF_1.Incidentx) AS SLAFailed FROM .SRFILE INNER JOIN BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = SRFILE.SRONUMBER WHERE (SRFILE.SR_GROUP = '38') AND (BSFLBWF_1.KPIFailx = '1') OR (BSFLBWF_1.SchoolChargex > '0.00') OR (BSFLBWF_1.LANMLEChargex > '0.00') GROUP BY BSFLBWF_1.CurrentCallOwnerx UNION SELECT BSFWES_1.CurrentCallOwnerx, COUNT(BSFWES_1.Incidentx) AS SLAFailed FROM SRFILE AS SRFILE_1 INNER JOIN BSFWES AS BSFWES_1 ON BSFWES_1.Incidentx = SRFILE_1.SRONUMBER WHERE (SRFILE_1.SR_GROUP = '38') AND (BSFWES_1.KPIFailx = '1') OR (BSFWES_1.SchoolChargex > '0.00') OR (BSFWES_1.LANMLEChargex > '0.00') GROUP BY BSFWES_1.CurrentCallOwnerx) AS derivedtbl_1 GROUP BY CurrentCallOwnerx, SLAFailed
I have a table line (ID, LineNo, LineName) having values as :
1, 1, <blank> 2, 2, <blank> 3, 3, <blank>
ID is PK with Auto-Increment and LinNo(I am manually incrementing through ASP.Net Page while record insertion) Now i have to write a query such that it updates LineName column from line table which is blank(as shown above) with values from table linet(linenamet) having values as :
a b c
My trial query is : update line set LineName = (select linenamet from linet);
It gives ERROR as : Subquery returns more than 1 row Expected Result : After Updation it should show line table as : 1, 1, a 2, 2, b 3, 3, c
I'm working on an ecommerce project that is missing 5,000 product pictures.
I am trying to assign all products without pictures into a category located on a mapping table.
I know an insert can be accomplished from one table (or subquery) to another but I only need to find the product IDs and insert them with default values into the category mapping table that has all non-null columns.
The following code is the farthest I can get without help (I'm not strong in SQL), it won't work because my subquery returns many rows while the SQL statement is designed to insert one - I don't know how to handle this...
[Code]....
Any help would be appreciated from those more experienced than I. BTW... there are no known search results for this type of solution - if there is even a solution.
I need to write a query as follows which will be bound to a grid
select top 25 * from ErrTable Order by DateErrorad Desc
However, I need to write this query to return only 25 records at a time, but when a user clicks next it will display the next 25 most recent records from the db.
i am having a problem on my aspx page, what i did was i wrote a simple url re-wrte rule in my aspx page, after i write my url re-write rule my query string looks like this [URL] idea been to writing a rule to accept that above query for user friend seo url string, but when i am in that page i cant click any of my datalist page indexes ...it will redirect to [URL] i dont know how to fix this proble, i am trying s hard ,but i cant make it work, i think page post back changing my url re-write link.
Being new to Linq and Entity Framework, I find myself struggling to write queries that are relatively simple in SQL. My latest challenge is how to write a query that pulls records from a master table and includes a column for aggregating data from related detail records. Let's start with this example:
List<Customer> list = (from x in Customer select x.Customer_ID, x.CustomerName).ToList();
Now I'd like to modify this so that I include a column indicating how many orders each customer has, where there is a one-to-many relationship between the Customer and Order entities. I suspect the solution might result in a List of an anonymous type rather than the List of Customer like my example, but that would be
I have the following code which writes to a Gridview:
[Code]....
Using the same methods of connecting to the database, how can I amend this code to write the result of a second query (which only returns a number) to a label?
Need to figure out the correct way to do a simple SUM function in Linq, but also manipulate one of the feilds coming back by doing a Substring on it, here is the original SQL query:
i have a table for customer forecast with following fields.. customer, year, week, quantity. now i need to write the SP to retrive the records based on the from week,year and to week,year... like this... from 45th week of 2009 to 25th week of 2010. how can write the query...