Filter Query Results

Nov 22, 2007

Hi,

I have an interface that allows the user to filter the data to be returned.

e.g. if the user selects @SeniorManager then the query should return all data related to this.

So if the user selects @SeniorManager and @Auditor then the query should return all data matching both @SeniorManager AND @Auditor.

FundID and ClientID are the ID's that link each table.

Am I correct in using UNION ALL below?? thanks.





Code Block
SELECT SeniorMgr, null AS Auditor, null AS Legal
FROM FundClient f
INNER JOIN FundPortfolio p
ON p.ClientID = f.ClientID
INNER JOIN Staff s
ON (s.ClientID = p.ClientID) AND (s.FundID = p.PortfolioID) AND (s.ClientID = f.ClientID)
WHERE s.ClientID = @ClientID AND s.FundID = @FundID
AND (@SeniorManager = null Or SeniorMgr = @SeniorManager)
UNION ALL

SELECT null AS SeniorMgr, fa.Auditor, null AS Legal
FROM FundClient f
INNER JOIN FundPortfolio p
ON p.ClientID = f.ClientID
INNER JOIN (Auditor a
INNER JOIN FundAuditor fa
ON fa.AuditorID = a.Auditor)
ON (a.ClientID = p.ClientID) AND (a.FundID = p.PortfolioID) AND (a.ClientID = f.ClientID)
WHERE a.Auditor = @Auditor
AND a.ClientID = @ClientID AND a.FundID = @FundID

UNION ALL

SELECT null AS SeniorMgr, null AS Auditor, fl.Legal
FROM FundClient f
INNER JOIN FundPortfolio p
ON p.ClientID = f.ClientID
INNER JOIN (Legal l
INNER JOIN LegalCounsel fl
ON fl.LegalID = l.Legal)
ON (l.ClientID = p.ClientID) AND (l.FundID = p.PortfolioID) AND (l.ClientID = f.ClientID)
WHERE l.LegalC = @Legal
AND l.ClientID = @ClientID AND l.FundID = @FundID





View 8 Replies


ADVERTISEMENT

Need To Display Results Of A Query, Then Use A Drop Down List To Filter The Results.

Feb 12, 2008

Hello. I currently have a website that has a table on one webpage. When a record is clicked, the primary key of that record is transfered in the query string to another page and fed into an sql statement. In this case its selecting a project on the first page, and displaying all the scripts for that project on another page. I also have an additional dropdownlist on the second page that i use to filter the scripts by an attribute called 'testdomain'. At present this works to an extent. When i click a project, i am navigated to the scripts page which is empty except for the dropdownlist. i then select a 'testdomain' from the dropdownlist and the page populates with scripts (formview) for the particular test domain. what i would like is for all the scripts to be displayed using the formview in the first instance when the user arrives at the second page. from there, they can then filter the scripts using the dropdownlist.
My current SQL statement is as follows.
SelectCommand="SELECT * FROM [TestScript] WHERE (([ProjectID] = @ProjectID) AND ([TestDomain] = @TestDomain))"
So what is happening is when testdomain = a null value, it does not select any scripts. Is there a way i can achieve the behaivour of the page as i outlined above? Any help would be appreciated.
Thanks,
James.

View 1 Replies View Related

Filter Double Results From Query

Nov 14, 2007

We are working on an application which aggregates news articles from various sources. The problem is, when querying the database, is that there are a lot of double results because some of the sources get their news from the same press agency. To clarify things a bit here's a link to an example:
http://84.244.146.27/Zoekresultaten.aspx?SearchQuery=Amsterdam
As you can see, there are a lot of the same results. What we want is to filter out the double results irrespective of the source. In other words; when the query encounters the first result, display that and leave out the other same results.
I've tried filtering them out by using DISTINCT on the 'news header' / results, but that does not seem to work. Any ideas on how to get this done?
Any help is greatly appreciated!
 

View 5 Replies View Related

Can You Filter SELECT Results?

Jul 23, 2005

I want to create a stored procedure that returns a list of records froma table. But depending on a userID value given only certain recordswill be returned that they have access to.I think this might be hard to do in a single SELECT statement becausethe user might also belong to a group that might have permission, etc.Can you do something like this pseudo code in a T-SQL procedure?DECLARE cur CURSOR FOR SELECT * FROM myTableOPEN curFETCH NEXT FROM curWHILE @@FETCH_STATUS = 0BEGINif( accessGranted(curRecord.id) ){ addRecordToResultSet() }else { ommitRecordFromResultSet() }END

View 11 Replies View Related

Using DropDownList And TextBox To Filter Results...

Aug 5, 2006

Hey all,
I've been searching for a while and haven't really found an answer for what I'm trying to do. Here it all is and someone can tell me if I'm going in the wrong direction to solve this.
I have a textbox set to a parameter of "SearchString" and a DropDownList with the SelectedValue paramter of "FilterValue". The parameters work, I've tested that. So here is the problem.
I am trying to use the "FilterValue" to pick the field that the "SearchString" searches with a  LIKE statement (e.g. SELECT * FROM dbo.Units WHERE (@FilterValue LIKE '%'+@SearchString+'%'))
This, I've found out, doesn't work. I have this setup with a DataLayer.vb in my App_Code directory handling the SQL calls, while the normal CodeBehind is in the typical "Default.vb" page.
I will post code later as I don't have access to it right now, but if anyone can explain how a filter like this would work I would appreciate it!
Thanks,
 
-Matthew

View 3 Replies View Related

SQL Server 2012 :: List Of Order Numbers Based On Stock Availability - Filter Results?

Dec 23, 2014

Trying to build a list of order numbers based on stock availability.

The data looks something like this:

OrderNumber Stockcode quantityordered quantityinstock
123 code1 10 5
123 code2 5 10
124 code3 15 20
124 code4 10 10

In this case I would like to output a single result for each order, but based on stock availability order 123 is not a complete order and 124 is so the results will need to reflect this.

View 1 Replies View Related

Is There A Way To Hold The Results Of A Select Query Then Operate On The Results And Changes Will Be Reflected On The Actual Data?

Apr 1, 2007

hi,  like, if i need to do delete some items with the id = 10000 then also need to update on the remaining items on the with the same idthen i will need to go through all the records to fetch the items with the same id right?  so, is there something that i can use to hold those records so that i can do the delete and update just on those records  and don't need to query twice? or is there a way to do that in one go ?thanks in advance! 

View 1 Replies View Related

How Do I Add A Filter To This Query?

May 3, 2006

I'm an MDX newbie.. with some help I was able to create a query that returns accurate results. All I need to do now is filter for Completed Work value of greater than 0.


I have tried to use the filter wizard in VS2005, but I have never gotten the desired results.




Platform Info:
SQL Server 2005 Standard
VS2005



---------Start Statement----------------------------------------------------------
WITH

MEMBER [Measures].[Completed Work by WI on dt1] AS

(

[Assigned To].[Person].CurrentMember,

[Work Item].[System_Id].CurrentMember,


[Date].[Year Week Date].[Date].&[2006-04-23T00:00:00],

[Measures].[Microsoft_VSTS_Scheduling_CompletedWork]

)

MEMBER [Measures].[Completed Work by WI on dt2] AS

(

[Assigned To].[Person].CurrentMember,

[Work Item].[System_Id].CurrentMember,

[Date].[Year Week Date].[Date].&[2006-04-29T00:00:00],

[Measures].[Microsoft_VSTS_Scheduling_CompletedWork]

)

MEMBER [Measures].[Completed Work] AS

[Measures].[Completed Work by WI on dt2] - [Measures].[Completed Work by WI on dt1]

SELECT
NON empty
{
[Measures].[Completed Work]

}

ON COLUMNS,

NON EMPTY

{
([Assigned To].[Person].[Person],[Work Item].[System_Id].[System_Id],[Work Item].[System_Title].[System_Title])


}

ON ROWS

FROM

[Team System]

----------End Statement---------------------------------------------------

View 1 Replies View Related

FILTER For MDX Query

Feb 17, 2012

I've got an MDX query I need to modify, but not quite sure how to proceed. I essentially know most of tye syntax, but am at a loss as to where the components of the syntax should appear in the query. Here is the original query:

Code:

WITH
MEMBER [Employee].[FTE vs FL].[CF Total] AS AGGREGATE([Client Facing Disciplines])
MEMBER [Time].[Year - Half Year - Quarter - Month - Date].[Trailing 12 Months] AS AGGREGATE(LASTPERIODS(60, STRTOMEMBER(@SelectedMonthEx, CONSTRAINED)))
MEMBER [Time].[Year - Half Year - Quarter - Month - Date].[YTD] AS AGGREGATE(YTD(STRTOMEMBER(@SelectedMonthEx, CONSTRAINED)))

[Code] ....

This is how I'm sure the two lines that say what should be excluded, I'm just not sure where they should go. I believe a FILTER statement is what I need, but not sure how to format it.

[Employee].[FTE vs FL].[Discipline].&[LOYALTY],
[Employee].[FTE vs FL].[Discipline].[Department].&[OLSON PR Chicago]

MDX is definitely not my strong point.

View 4 Replies View Related

Help With A Filter Query

Dec 20, 2007

Hello ,
I am Joining two tables and trying to filter the data based on some conditions.
SELECT SERVICE_TICKET.SERVICE_TICKET_CODE,BuildingAddress.BuildingAddress, BuildingAddress.UserID,SERVICE_TICKET.PROBLEM_REPORTED, SERVICE_TICKET.CONTACT_PERSON, SERVICE_TICKET.STATUS FROM BuildingAddress INNER JOIN SERVICE_TICKET ON BuildingAddress.Customer_Site_Int_ID = SERVICE_TICKET.CUST_SITE_INT_ID WHERE (JoinTable.UserID = @parameter) AND (SERVICE_TICKET.SERVICE_TICKET_CODE LIKE 'HD' + '%')
See in the query at the WHERE clause I am using JoinTable.UserID column actually I know that it is wrong . Could some one tell me how the query should be so that I can get the records from the join which matches the UserID column to a parameter.
Hope that my question is clear.
Thanks

View 4 Replies View Related

Query Ignoring Filter?

Feb 29, 2008

All,

So I have this query that is ignoring my date filter and for the life of me I can't figure out why. Was hoping some guru could explain it to me. Here goes:

This query ignores my date filter:

SELECT
rcv.Name AS MachineName,
r.JobId,
j.Name AS JobName,
r.CreateTime AS JCreateTime,
rsv.Name AS JResultStatus,
rpv.Path + rpv.Name AS ResourcePool,
rcvv.ResourceConfigurationVal AS Dimension

FROM
dbo.Result_View AS r
INNER JOIN dbo.ResourceConfiguration_View AS rcv ON r.ResourceConfigurationId = rcv.Id
INNER JOIN dbo.Job_View AS j ON r.JobId = j.Id
INNER JOIN dbo.ResultStatus_View AS rsv ON r.ResultStatusId = rsv.Id
INNER JOIN dbo.Resource_View AS rv ON rcv.ResourceId = rv.Id
INNER JOIN dbo.ResourcePool_View AS rpv ON rv.ResourcePoolId = rpv.Id
RIGHT JOIN dbo.ResourceConfigurationValue_View AS rcvv ON rv.LatestResourceConfigurationId = rcvv.ResourceConfigurationId
LEFT JOIN dbo.Dimension_View AS d ON rcvv.DimensionId = d.Id

WHERE
(r.CreateTime > DATEADD(DAY, -15, GETDATE()))
AND
(rcv.Name LIKE 'PNP%')
AND
(d.Id = 859)
OR
(d.Id = 860)

If I comment out the last two joins and associated select/filters, all of the sudden the date filter works again. From everything I have read, the joins are supposed to be processed BEFORE the filters are applied in the virtual table. My DB goes back a number of years and contains millions of records. W/O the date filter, the query takes a very, very long time to run.

Any ideas on why this would happen?

Thanks,

Allen

View 5 Replies View Related

Query Diff Results From Ent Manager Query And Query Analizer

May 28, 2008

ok can someone tell me why i get two different answers for the same query. (looking for last day of month for a given date)

SELECT DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(m, 0, CAST('12/20/2006' AS datetime)) + 1, 0)) AS Expr1
FROM testsupplierSCNCR
I am getting the result of 01/01/2007

but in query analizer I get the result of

12/31/2006

Why the different dates

View 4 Replies View Related

Filter Query On Profile Property

Nov 1, 2006

Hello All, Can someone please help me with this problem.  I have created additional profile properties for my users in the aspnet_profile table.  One of the properties is named 'Division'.  The division property is how I segregate users, for example, my company has multiple divisions and, the information that is displayed is dynamic according to which divison the user belongs to. Amost all of my stored proceedures are filtered by checking the value of Profile.Division of the logged in user. This system works great.  The problem is, now I am working on user management and I need to create a Gridview that will display all of the users for a particular division but, I have no idea how to filter a query against the aspnet database to get the results I am looking for.  Here is a small example:SELECT     aspnet_Users.UserName, aspnet_Profile.PropertyNames, aspnet_Profile.PropertyValuesStringFROM         aspnet_Profile INNER JOIN                      aspnet_Users ON aspnet_Profile.UserId = aspnet_Users.UserId********   Here is the part I need help with *********************WHERE  PROFILE.DIVISION = KOr, can it even be done? Can you filter a query on the value of a profile property?Anyone have any ideas?Thanks in adavance for your help

View 2 Replies View Related

How To Query Data By Various Amount Of Filter Value ????

Jul 2, 2007

Generally, on any screen, we design filter screen by allowing user to identify range or one value to search.
But sometime in some screen, It will be more convenient for user if user can identify No matter how value to search.
 
For example
On screen which have information of people in any province.
So user would like to search it by identify no matter how value to search.
There are check box of any province on filter part which enable users choose it.
 
Hence, if sometime user choose (by clicking on checkbox) 3 provinces : LA, Michigan, WachingtonDC  to see description only 3 chosen province.
and sometime user choose (by clicking on checkbox) 2 provinces : LA, Michigan to see description only 2 chosen provinces.
 
Please give me any idea for create Stored Procedure or any tecnique to complete my idea....
 
 
Help me Pleaseeeee

 
 
 

View 1 Replies View Related

Help On Adding Another Filter Statement On The Query

May 27, 2008

Hi everybody have this query that list all the duplicate records meaning the occurence of pubinfid in more than one row. This gets me fine. Iwant thought to insert a where clause that further filters the result where pubid between 30 and 33. I tried placing it after the FROM CLAUSE BUT DOESN'T GIVE me what I want it still includes records other than the between clause. Also I tried placing it after the HAVING clause but it includes records which has only one count.. Where could I place the where clause or is ther an alternative for this.



SELECT a.pubinfid, a.pubid, a.pubcount
FROM pubssubscribe AS a INNER JOIN
(SELECT pubinfid
FROM pubssubscribe
GROUP BY pubinfid
HAVING (COUNT(*) > 1)) AS b ON a.pubinfid = b.pubinfid



thanks

View 8 Replies View Related

Query To Filter Alphanumeric Data?

Dec 4, 2011

I have alphanumeric data in a Table Assets. The column name is Milepost.

Column Values are like below

MilePost

1.24
1.61
4.56
4.78
5.45
6.91
7.19

[code]....

Now I want to select records between 1 to LR 4.41 which should return all records between 1 to LR 4.41

My below query is not returning proper values. So i need a correct sql query.

Select Milepost from Assets where Milepost between '1' and 'LR 4.41'

View 4 Replies View Related

Structure Or Syntax For Query / Filter

Apr 23, 2015

I need to find a 12-digit number in a column called "SequenceNumTxt", in a VERY long table.I can query the first n lines but need to add something like "WHERE [SequenceNumTxt]="123412341234".The above does not work, gives me a syntax error; what am I doing wrong?

View 7 Replies View Related

Automatic Select Filter (something Like Global Table Filter)

Apr 15, 2008

Hello,

Here is my problem:


I use SQL Server 2005. I have approx. 50 tables in my database and 30 of them have a filed named "CompanyID". Example:
create table A (ID int identity, NAME varchar(100), COMPANYID int)create table A (ID int identity, REF_ID int, FIELD1 varchar(100), FIELD2 varchar(100), COMPANYID int)

Also there are nearly 200 stored procedures that read data from these tables. Example:
create procedure ABCasbegin /* some checks and expressions here ... */ select ... from A inner join B on (A.ID = B.REF_ID) where ... /* ... */end;

All my queries in the Stored procedure does not filter the tables by CompanyID, so they process the entire data.

However, now we have a requirement to separate the data for each company. That means that we have to put a filter by CompanyID to each of those 20 tables in each query where the tables appear.

Firstly, I put the CompanyID in the context so now its value is accessible through the context_info() function. Thus I do not need now to pass it as a parameter to the stored procedures.

However, I don't know what is the easiest and fastest way to filter the tables. Example:

I modified the above mentioned procedure in the following way:
create procedure ABCasbegin /* some checks and expressions here ... */
-- gets the CompanyID from the context: DECLARE @CompanyID int; SELECT @CompanyID = CONVERT(float, CONVERT(varchar(128), context_info()))
select ... from A inner join B on (A.ID = B.REF_ID) where ...
and A.COMPANYID = @CompanyID and B.COMPANYID = @CompanyID /* ... */end;

Now I have the desired filter by CompanyID. However, modifying over 200 stored procedures is rather tedious work and I don't think that this is the best approach. Is there any functionality in SQL Server that can provide the possibility to put an automatic filter to the tables.
For example: when I wrote "SELECT * FROM A", the actual statements to be executed would be "SELECT * FROM A WHERE CompanyID = CONVERT(float, CONVERT(varchar(128), context_info()))".

I was looking for something like "INSTEAD OF SELECT" triggers but I didn't manage to find any answer.

I would very grateful is someone suggests a solution for something like "global table filter" (that will help me make an easy refactoring)?


Thanks in advance.

Best regards,
Beroetz

View 5 Replies View Related

Using A Date Filter In Query With (&< Or &>) Fails But With (=) Works ???

May 11, 2006

I have a simple ASP.NET application that allows the user to enter a Query in a TextArea and submit that to the database. Queries that contain Integer, String or other filters seem to work fine, but when the Query contains a Date or DateTime I have problems.
Here is an example that works fine in Query analyzer but fails when executed in ASP.NET.
"select top 10 * from Subscribers where StartDate < '09-03-2002'"
In Query Analyzer no problem, in ASP.NET I get this error...
Line 1: Incorrect syntax near ';'
However if the Query uses '=' instead of a '<' or '' then it works without error
"select top 10 * from Subscribers where StartDate ='09-03-2002'"
Any help would be appreciated

View 3 Replies View Related

How To Add Date Range Filter To Database Query

Jul 12, 2012

how to add a date range filter to my database query. I want to be able to enter a date into ("E,6") and have VBA pull data >,= to that date range according to my "OPENED_DATE" dates. My code is pasted below:

'Create header names
wkbOne.Worksheets("Sheet1").Cells(1, 1).Value = "PART_NUMBER"
wkbOne.Worksheets("Sheet1").Cells(1, 2).Value = "SFC"
wkbOne.Worksheets("Sheet1").Cells(1, 3).Value = "OPERATION"
wkbOne.Worksheets("Sheet1").Cells(1, 4).Value = "NC_CODE"
wkbOne.Worksheets("Sheet1").Cells(1, 5).Value = "OPENED_DATE"

[code]....

View 1 Replies View Related

Query To Filter Duplicate Data From Table.

Apr 8, 2004

i am having 3000 records in table. now i want take out the duplicate from that table.

for example: i want to find out the duplicates of 'CompanyNames'.

help needed to write query for this operation.

View 2 Replies View Related

SQL 2012 :: Query To Filter Out Specific Data?

Aug 21, 2015

I need to return 1 ip address for each machine. I can easily achieve this with using group by and return max(ipaddress) however I would like to filter out specific range '192.168.%' but only want to do that if machine has more then 1 ip address. If the machine has only 1 ip address then it can return it even if its '192.168.%'

below is test table to show sample data

CREATE TABLE dbo.[testip](
[machineid] INT NULL,
[ipaddress] [varchar](20) NULL
)
GO
INSERT INTO [dbo].[testip] ([machineid],[ipaddress]) VALUES (1,'155.119.1.22')
INSERT INTO [dbo].[testip] ([machineid],[ipaddress]) VALUES (1,'192.168.1.5')

[code]....

View 4 Replies View Related

SQL Sever Side Query To Filter For User ID

Apr 23, 2008

I currently have a query in an access database that filters the records in a Sql Linked table for their user ID. So basically i use Environ("UserName") to filter for a field that contains their user name. I want to secure this and put it on the SQL Server so there is no way anyone can see any records other then the ones that are filtered for them. Does anyone know how to do this? I think it will be some SQL query.

I'm still learning sql server 2005.

Thanks.

View 3 Replies View Related

Transact SQL :: Filter - Join Query Rows

Nov 14, 2015

Please refer to the below query. I want to filter inner join rows based on outer query column value (refer to bold text).

SELECT M.MouldId, SI.StockCode, MI.Cavity, MI.ShotCounter, CQ.SumOfCastedQty  as CastedQty, MI.CounterStartup 
FROM        MouldItem MI
JOIN (SELECT JD.MouldId, JC.StockCode, SUM(JS.CastedQty) AS SumOfCastedQty
FROM JobCasting AS JS INNER JOIN JobCreationDet AS JD ON JS.JobDetId = JD.Uniid INNER JOIN JobCreation AS JC ON JD.JobIdx = JC.Uniid

[Code] ....

View 2 Replies View Related

Filter Dynamically Created Data Tables Using Sql Query

May 24, 2008

Hi friendsI have little problem here.I am creating data tables dynamically.I want to filter it using sql query.Suppose,
I have four data tables with the same structure but records may be
different.There are two fields ServiceMethod and Rates.Now I want to filter all tables and want to get match records with the ServiceMethod.Suppose,four records in First table,three records in other three tables,and only two records(Service method) are same in all tables.I
want to that two records by filtering all tables and sum of rates and
want to add matched records in new table and bind dropdownlist.Can any guide me how to filter more than one tables using sql query if data tables are created dynamically?Thanks in advance. 

View 2 Replies View Related

Filter Query By Year And Change Dated Automatically

Jan 21, 2014

I have a data column named Date_In with format of 20-May-13. How can I filter the data to select based on year only. I used

Select
*
From apps.xdmc_852@erpprod
Where Year(Date_in) = 2014

This code is not working. I also need a way to automatically update to next week range. For example, last week I used where function like this

Where Date_in = to_date('01/12/2014','MM/DD/YYYY')

Is there a way it will automatically at the next 7 days to the code above when the date is available. This week I have to go back and changed the code in to this:

Where Date_in = to_date('01/19/2014','MM/DD/YYYY')

View 3 Replies View Related

Transact SQL :: Create A Function To Define Query-filter

Jul 6, 2015

Is there a way to define a query-filter (Example: WHERE column1 > 5 AND column2 = 'value') in a function?

So I can create a query like this:

SELECT *
  FROM Table
  WHERE MyFunction()

I know it's a bit of a strange question, but I'm writing a dynamic software that will have the ability to run Stored Procedures on any database to create some data-checks. Through parametrisation, a user can define for a specific Stored Procedure that some results are no longer necessary in the result-set.

Example:
ID - Name - State
1 - Jozef De Veuster - Mad
2 - Piet Husentruut - Not Happy
3 - Jeroen Meus - Angry

Is the result of a Stored Procedure "Show_me_unhappy_persons". But we already know that Jozef De Veuster is ALWAYS Mad, so a user can say: Exclude ID = 1, so it won't appear anymore in the result.

I want to handle this by doing:

SELECT *
FROM PeopleStates
WHERE --Some stuff--
AND CheckUserExclusions(SomeID)
And CheckUserExclusions will translate to "NOT (ID = 1)"

View 14 Replies View Related

Query Fails With Invalid Column Name But Succeed As Sub-query With Unexpected Results

Sep 22, 2015

-- The 3rd query uses an incorrect column name in a sub-query and succeeds but rows are incorrectly qualified. This is very DANGEROUS!!!
-- The issue exists is in 2008 R2, 2012 and 2014 and is "By Design"

set nocount on
go
if object_id('tempdb.dbo.#t1') IS NOT NULL drop table #t1
if object_id('tempdb.dbo

[code]....

This succeeds when the invalid column name is a valid column name in the outer query. So in this situation the sub-query would fail when run by itself but succeed with an incorrectly applied filter when run as a sub-query. The danger here is that if a SQL Server user runs DML in a production database with such a sub-query which then the results are likely not the expected results with potentially unintended actions applied against the data. how many SQL Server users have had incorrectly applied DML or incorrect query results and don't even know it....?

View 2 Replies View Related

Transact SQL :: Adding Results Of Query To Another Query Via Dynamically Added Columns

Jul 30, 2015

For each customer, I want to add all of their telephone numbers to a different column. That is, multiple columns (depending on the number of telephone numbers) for each customer/row. How can I achieve that?

I want my output to be

CUSTOMER ID, FIRST NAME, LAST NAME, TEL1, TEL2, TEL3, ... etc

Each 'Tel' will relate to a one or more records in the PHONES table that is linked back to the customer.

I want to do it using SELECT. Is it possible?

View 13 Replies View Related

Easy SQL Question. How To Display Query Results In Query Analyzer

Feb 12, 2008

When I run the following query from Query Analyzer in SQL Serer 2005, I get a message back that says.
Command(s) completed successfully.
What I really need it to do is to display the results of the query. Does anyone know how to do this?
declare     @SniierId as   uniqueidentifierset @SniierId = '85555560-AD5D-430C-9B97-FB0AC3C7DA1F'declare    @SniierAlias  as nvarchar(50)declare    @AlwaysShowEditButton  as bitdeclare     @SniierName  as  nvarchar (128)/* Check access for Sniier */SELECT TOP 1       @SniierName      = Sniiers.SniierName,        @SniierAlias    = Sniiers.SniierAlias,        @AlwaysShowEditButton = Sniiers.AlwaysShowEditButtonFROM SniiersWHERE Sniiers.SniierId=@SniierId

View 3 Replies View Related

And/or Filter Field Not Enabled In The Group Filter Tab

Jan 26, 2006

Howdy,

I have a table that has a group. In this group, I want to filter by 2 different expressions, concatenated with an OR. BUT I can't change the "And/Or" column value for the first entry because it is grayed out. The column will automatically change to an OR value if both my expression column fields are the same (which I don€™t want) but if I put any other value in to the expression field of the second row, the "And/Or" field of the first row automatically changes to an AND.

PLEASE! How do I get the And/Or field "ungrayed" so I can change it to what I want?

The 2 filters I and using check the UserID = to the user, and the other is checking a count to get the Top N 1. (So just showing the current user and the top producer)

View 14 Replies View Related

In Query Builder Design View, How Does The Filter Operator MDX Work?

Nov 12, 2007

Good morning all,

I have searched everywhere for this and I can't find any information on it. When I use the Query Builder, in the top pane, the Filter pane, there are five columnsimension, Hierarchy, Operator, Filter Expession and Parameters.

In the dropdown for Operator, one of the choices is MDX. I cannot find any documentation on how to use this operator. I want to limit my filter to SELF_AND_AFTER, and I am hoping that this is possible using this operator. I know how to hand code it, but I have a ton of other tweaks to make to the query, so I want to use the Query Designer as much as I can.

Does anyone have any links to documentation on how to use this operator?

Thanks,
Kathryn

View 2 Replies View Related

Returning Results Based On One Query Into Existing Query

Aug 2, 2012

linking two tables together to get an end result

find below the code i have used

The first part of the query provides me with the info i need

SELECT sub.*,
case when rm_sales_band = '2M to 4M' then 'Kirsty' else RM end as rm
into #rmtmp

[Code].....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved