Hiding/Showing Columns Based On The Columns Present In The Dataset

Jun 27, 2007

I have query which retrieves multiple column vary from 5 to 15 based on input parameter passed.I am using table to map all this column.If column is not retrieved in the dataset(I am not talking abt Null data but column is completely missing) then I want to hide it in my report.

Can I do that??

Any reply showing me the right way is appricited.



-Thanks,

Digs

View 3 Replies


ADVERTISEMENT

Reporting Services :: Hiding A Row Based On A Value But Showing It For Others?

Nov 18, 2015

I need to hide a row based on a value but show it for the rest of the values! this is the expression i am using for the first row is

=IIF(Fields!QuestionRef.Value = "1.2" or  "2.1" or "10.2" or "20.2" or "23.2" or "30.1",  true , false)

And for the second row 

=IIF(Fields!QuestionRef.Value = "1.2" or  "2.1" or "10.2" or "20.2" or "23.2" or "30.1", true, false)

But it either hides the row for all values or shows it for all values.

View 5 Replies View Related

Reporting Services :: Hiding Column Based On A String Value But Showing It For Others?

Nov 20, 2015

I need to hide a column just for certain values from a table like contract decorators I tried using

=IIF(Fields!MainTrade.Value = "Contracts Decorator, Bricklayer", True, False)

But it just hid the column for all values, then i tried this but it doesn't seem to work (Think it's not correct though)

=IIF(Instr("Contracts Decorator, Bricklayer","," & Fields!MainTrade.Value & ",") > 0,true , false).

Below is the table and the highlighted column i am trying to hide just for those two fields. The table has a page break so that it would be displayed on a different page for each value, but i'm not sure it is possible as i have only done it for integers and rows before.

View 16 Replies View Related

Calculated Columns Based On Multiple Columns?

Aug 12, 2014

MS SQL 2008 R2

I have the following effectively random numbers in a table:

n1,n2,n3,n4,SCORE
1,2,5,9,i
5,20,22,25,i
6,10,12,20,i

I'd like to generate the calculated column SCORE based on various scenarios in the other columns. eg.

if n1<10 and n2<10 then i=i + 1
if n4-n3=1 then i=i + 1
if more than 2 consecutive numbers then i=i + 1

So, I need to build the score. I've tried the procedure below and it works as a pass or fail but is too limiting. I'd like something that increments the variable @test1.

declare @test1 int
set @test1=0
select top 10 n1,n2,n3,n4,n5,n6,
case when (
n1=2 and
n2>5
)
then @test1+1
else @test1
end as t2
from
allNumbers

View 5 Replies View Related

Hiding Secret Columns From Users

Nov 23, 2005

Hi,On my SQL Server 2000, I have a table of data (tblAllData) containing anumber of columns, some of which are 'secret'.I have to let some users access the database using ODBC from an Excelsheet, and I would like that they do not know at all that the columns exist.I tried creating a view for them (qryAllData) that only selects thecolumns that should be visible, but when the creating theODBC-connection, both the query and the underlying table shows up.If I select the table as datasource, the query-builder in excel shows alist of all the columns, including the secret ones. If I try selectingthen, of course, an error occurs.I would like either that the columns for the table don't show or thatthe table does not show at all - and only reveals the existence of theview to the odbc-client.Is that possible?Here's what I tried so far:<pre>USE DbAllDatasp_addlogin @loginame='ODBCAccess', @passwd='ODBCAccess', @defdb='DbAllData'sp_grantdbaccess 'ODBCAccess'sp_addrolemember @rolename = db_denydatawriter, @membername = ODBCAccessREVOKE ALL FROM ODBCAccessDENY SELECT ON dbo.syscolumns TO ODBCAccessDENY SELECT ON dbo.syscomments TO ODBCAccessDENY SELECT ON dbo.sysdepends TO ODBCAccessDENY SELECT ON dbo.sysfilegroups TO ODBCAccessDENY SELECT ON dbo.sysfiles TO ODBCAccessDENY SELECT ON dbo.sysfiles1 TO ODBCAccessDENY SELECT ON dbo.sysforeignkeys TO ODBCAccessDENY SELECT ON dbo.sysfulltextcatalogs TO ODBCAccessDENY SELECT ON dbo.sysfulltextnotify TO ODBCAccessDENY SELECT ON dbo.sysindexes TO ODBCAccessDENY SELECT ON dbo.sysindexkeys TO ODBCAccessDENY SELECT ON dbo.sysmembers TO ODBCAccessDENY SELECT ON dbo.sysobjects TO ODBCAccessDENY SELECT ON dbo.syspermissions TO ODBCAccessDENY SELECT ON dbo.sysproperties TO ODBCAccessDENY SELECT ON dbo.sysprotects TO ODBCAccessDENY SELECT ON dbo.sysreferences TO ODBCAccessDENY SELECT ON dbo.systypes TO ODBCAccessDENY SELECT ON dbo.sysusers TO ODBCAccess--allow selectingGRANT SELECT (idx, col1, col2) ON tblAllData TO ODBCAccessGRANT SELECT ON qryAllData TO ODBCAccess</pre>TIA,M

View 5 Replies View Related

Table Not Centering After Hiding Two Of Its Columns

Dec 31, 2007



I have a table with 7 columns and it centers perfectly on my report. However, based on what the user selects when running this report, two of the columns can end up hiding. When I hide these two columns, which happen to be in the middle of the table, the table then appears to be left aligned because two of the columns are now gone so everything shifts.

The only reason its centered with 7 columns is because I have streteched all the columns out to certain sizes to make everything fit on the page and this is what is lost when 2 of those columns are dynamically removed.

Is there a way to keep everything centered even with these two columns gone? Is there a better way to ensure centering now matter how many columns exist in a table?

Thanks,
Flea

View 1 Replies View Related

How To Present An Unknown Number Of Columns And Their Names

Aug 14, 2001

I've got a database with an unknown number of columns. Hence, the column names are also unknown. What's the easiest SQL to present the values in each column and the column headings?

View 1 Replies View Related

Dynamically Hiding Columns In A Matrix Report

Mar 5, 2008

Hi,


I am wondering if someone has some experience with hiding columns in a Matrix report. I have got two details columns: "Yr to Yr Credits Growth€? and "Yr to Yr Credits Growth %" and those two columns return only one value "N/A" for the earliest year since there is nothing to compare to. Thus, I don't really need them for the earliest year. On top of detail columns, I have got three matrix groups: matrix1-Year, matrix1-Quarter and matrix-Date. Once those two detail columns are hidden, I would like obviously resize (shrink) those three matrix groups columns to reflect the fact that the detail columns were hidden.

Thanks!

View 3 Replies View Related

Hiding Columns -White Space At End Of The Table*****Extremely Urgent

Mar 27, 2008

Hello everyone,
In reports ,My customer requirement is to display column based on selected criteria in UI .
The columns which are not selected by him will hide.
for that we kept an expression in Visibility --> Hide



Code Snippet
= NOT Parameters!Parameters.Value.ToString().Contains("Name")




then coming to HTML Report
It is working fine,but white space coming at end of the Table.
can't we supress the white space?
The white space width is exactly the width of the column which is hidden.
My designing in layout is wrong?
Else is that Problem with the SSRS?
Experts Please let me Know!!!!
Give me Solution!!!
Customer is strictly focusing on that requirement.

***Note: white Space is Some what Acceptable.But My Reports are very big like 45 columns around.When he selects 10 out of 45 then you can assume how much space is coming????????****

View 4 Replies View Related

RS2k Issue: PDF Exporting Report With Hidden Columns, Stretches Visible Columns And Misplaces Columns On Spanned Page

Dec 13, 2007

Hello:

I am running into an issue with RS2k PDF export.

Case: Exporting Report to PDF/Printing/TIFF
Report: Contains 1 table with 19 Columns. 1 column is static, the other 18 are visible at the users descretion. Report when printed/exported to pdf spans 2 pages naturally, 16 on the first page, 3 on the second, and the column widths have been adjusted to provide a perfect page span .

User A elects to hide two of the columns, and show the rest. The report complies and the viewable version is perfect, the excel export is perfect.. the PDF export on the first page causes every fith column, starting with the last column that was hidden to be expanded to take up additional width. On the spanned page, it renders the first column on that page correctly, then there is a white space gap equal to the width of the hidden columns and then the rest of the cells show with the last column expanded to take up the same width that the original 2 columns were going to take up, plus its width.

We have tried several different settings to see if it helps this issue or makes it worse. So far cangrow/canshrink/keep together have made no impact. It is not possible to increase the page size due to limited page size selection availablility for the client. There are far too many combinations of what the user can elect to show or hide to put together different tables to show and hide on the same report to remove this effect.

Any help or suggestion on this issue would be appreciated

View 1 Replies View Related

New View Not Showing Columns

Jul 9, 2001

Any idea why I cannot see (in Enterprise Manager) all the coulmns of a selected table? All I get is * all columns - not each one, meaning I cannot select individual columns in my new view. Could it be the version? I am running SQL 7.0 SP1

Thanks

View 2 Replies View Related

Matrix Report Not Showing All Columns

Jan 16, 2007

I have a matrix report that I am using with MonthName(Fields!Month.Value) across the top of the report. However, when there is no data under the column, the month is skipped. So, for example, I get this:

January March

Actual Goal Actual Goal

25 25 30 35



I have tried adding

iif(Sum(Fields!Total.Value, "DatasetName")> 0, Sum(Fields!Total.Value, "DatasetName"),"N/A")

But it still is not showing up.

Any ideas?

Thanks,

SHP



View 5 Replies View Related

Upstream Columns Not Showing In Merge

Aug 8, 2007

why wouldn't an upstream column show up in the merge editor?

I can see the column in the metadata by clicking the green arrow going into the merge, but it doesn't not show up as a selectable value in any of the drop downs.

this is true for input1 and input2 in the merge

anyone know how I can force it to show up?

View 4 Replies View Related

Calculating Percentages And Showing In Separate Columns

Aug 31, 2013

SELECT DISTINCT CASE WHEN SM.SERVICE_TYPE_N = 1 THEN 'LABORATORY'
WHEN SM.SERVICE_TYPE_N = 2 THEN 'PODIATRY'
WHEN SM.SERVICE_TYPE_N = 3 THEN 'ADMINISTRATION'
WHEN SM.SERVICE_TYPE_N = 4 THEN 'DIET'
WHEN SM.SERVICE_TYPE_N = 5 THEN 'DENTAL'

[Code] ....

In the above query i need to calculate 100%,30% and percentage other than 100 and 30 and show them in separate columns how to do that?

1)ROUND(SUM(BM.CONCESSION_AMOUNT_M),2)AS [100_PERCENT]
WHERE BM.BILL_AMOUNT_M=BM.CONCESSION_AMOUNT_M

2)ROUND(SUM(BM.CONCESSION_AMOUNT_M),2)AS [30_PERCENT]
WHERE AND BM.CONCESSION_AMOUNT_M=BM.BILL_AMOUNT_M * 0.30

3) ROUND(SUM(BM.CONCESSION_AMOUNT_M),2)AS [OTHER_CONCESSION_PERCENT]
WHERE BM.CONCESSION_AMOUNT_M between BM.BILL_AMOUNT_M*0.001 and BM.BILL_AMOUNT_M*0.299
OR BM.CONCESSION_AMOUNT_M between BM.BILL_AMOUNT_M*0.301 and BM.BILL_AMOUNT_M*0.999

View 3 Replies View Related

Select Query - Showing Columns Data Row Wise

Dec 28, 2011

I have get 3 columns in a select query. how can show these 3 columns in row wise.

View 2 Replies View Related

Columns Not Showing On Local Host Reporting Services?

Jun 4, 2007

i created a layout in visual studio 2005 with the proper dimensions to print on an Avery 5160 label sheet (3 labels across and 10 down)



in the Body properties, i set Columns to 3, ColumnSpacing to 0.125", and Size 2.625" (W) & 1" (H).



i created a list table with a text box of the same dimension as the Size in the Body.



the thing is when i go to preview the report in visual studio, it just shows all the data but only in one column, but if i click the Print Layout button, it shows all 3 columns, then when i print it, it works! so i assumed that this was just the way visual studio handled the data. no big deal...



the problem is when i upload this to the reporting services on our local intranet and run it from the reporting services, it shows only one column (the left most only) and prints that way too; it's almost like i need a Print Layout button on the reporting services (which there isn't one).



is there something that i need to set so that it will print in 3-column form from the reporting services so people can print on label sheets?



i hope this makes sense. also, i tested this on the same printer just to make sure it wasn't hardware.

View 3 Replies View Related

Rename The Columns Of A MDX Dataset

Mar 5, 2008



Hi,

I have a dataset in MDX using an OLE DB connexion. Here is the query:



Code Snippet
WITH
MEMBER [Number Proposal Issued] as
'[Measures].[# Proposal]'
MEMBER [Value Proposal Issued] as
'[Measures].[Amount - E]'
select
{ [Fact Proposal].[Proposal Status].allmembers*{[Number Proposal Issued],[Value Proposal Issued] }} ON 1
,non empty
[Time Key Issuing Date].[Month].children
ON 0
FROM [BV Sales DW]
where {[Time Key Issuing Date].[Year].&[2008]}




It is simple, it works. BUT, the dataset fields take the name of the returned columns and in this case, the [Time Key Issuing Date] values. The aim of this query is to be able to change the year at will (in the where).
For the moment, the fields has the full tuple name like Time_Key_Issuing_Date_Month__2008_1 for january. If I change the year to 2007, I will get Time_Key_Issuing_Date_Month__2007_1 so a different name.

So my question is: is there a way to call the first column for example "January" whatever the year is so I can call it in my report? Something like:

[Time Key Issuing Date].[Month].&[ (param year) ]&[1] as January
,[Time Key Issuing Date].[Month].&[ (param year) ]&[2] as February
...
on 0

I have tried to rename them in the dataset fields tab but when I put another name, it says the field doesn't exist.

We have managed to do it with code in the report but it a huge code not very easy to handle.

Thanks in advance for all help you can provide.

View 2 Replies View Related

Conditionally Showing/hiding A Parameter

Jul 16, 2007

I have a report that in most cases takes 4 parameters. In a few special cases, though, it takes 5 parameters. I have my code modified enough such that it can handle this exception, however I cannot figure out how to conditionally show the 5th parameter based on the 4th parameter. Is this possible?

View 3 Replies View Related

Adding 2 Columns In A Dataset As A Single Column In Datagrid

Nov 9, 2006

hi,
i am having 2 columns in a table in a dataset.
i want to add those two columns and bind the resultant total as a single column to the datagrid.
is it possible.
if yes, how o acheive this?
please help me.
thanks in advance.
muppidi.

View 1 Replies View Related

Reporting Services :: Dataset In Microsoft Report With Too Many Columns

Dec 1, 2015

I have a dataset with rows that I normally would display in a  table control. I have too many columns and I would like each data row to be display on many lines. How is that possible?

View 4 Replies View Related

Transact SQL :: Stored Procedure Not Returning Dataset (No Columns Are Coming)

Jun 3, 2015

We are facing an issue while executing a stored procedure which uses a table of current database with INNER JOIN a table of another database in same instance.

Per our requirement, we are inserting select statement output in table variable. Then applying business logic and finally showing the data from table variable.

This scenario is working exactly fine in Dev environment. But when we deployed the code in quality environment. Stored procedure does not returning OUTPUT/ (No column names) from table variable.

During initial investigation, we found that collation of these two databases are different but we added DATABASE_DEFAULT collation in the JOIN.

View 14 Replies View Related

Rows Based On Columns

Feb 3, 2008

I know this may have been asked before but can someone pls hel mw out here. i even tried to use the Crosstab SP that i found out on this site but it is not for what i need.

I have a Table/View called [Shipment] with the data below.

ShipNo Supplier
=================
1 CFA
1 TFA
2 LRA
2 LRB
3 ABC
4 TFA

I want the following as my result.

ShipNo Supplier1 Supplier2
==========================
1 CFA TFA
2 LRA LRB
3 AB
4 TFA

Thx.
Rav

View 6 Replies View Related

Reporting Services :: SSRS - Display Dataset Fixed Row As Report Columns

Jun 18, 2015

We are planning to develop weekly report in SSRS.For this we wants each day as column & some expenses[Numeric figure in row]we have dataset like 

day 
exp1
exp2
exp3
17/05/2015
120
150
650

[code]....

There are some other filters are there that i have applied in my report tablix property.

View 2 Replies View Related

Dataset Into A Table Or Matrix With Fixed Number Of Columns, Variable Rows

Jul 13, 2007

Hi

I have a dataset with 2 columns, a rownumber and a servername - eg



rownumber servername

1 server1

2 server2

....

15 server15



I want to display the servernames in a report so that you get 3 columns - eg



server1 | server2 | server3

server4 | server5 | server6

...

server13 | server14 | server15



I have tried using multiple tables and lists and filtering the data on each one but this then makes formating very hard - i either end up with a huge gap between columns or the columns overlap



I have also tried using a matrix control but cant find a way to do this.



Does anybody know an easy way to do this? The data comes from sql 2005 so i can use a pivot clause on the dataset if somebody knows a way to do it this way. The reporting service is also RS2005



Thanks



Anthony

View 1 Replies View Related

How To Do Update Of Select Columns Based On...

Jun 21, 2007

the following criteria.
i have the selection all done but am trying to figure out how to do the following:
if column4 < 0 then add column4 to column3, move 0 to column4;
if column3 < 0 then add column3 to column2, move 0 to column3;
if column2 < 0 then add column2 to column1, move 0 to column2;
add column3 to column4;
move column2 to column3;
move column1 to column2;
if column0 > 0 move column0 to column1, move 0 to column0 else move 0 to column1;

these are all numeric data types.

View 7 Replies View Related

Discovering AGE Based On Date Columns

May 28, 2008

Hello.

I have three INT columns in a table that record the users birth year, month, and day.

BDAY_DAY (INT)
BDAY_YEAR (INT)
BDAY_MONTH (INT)

I'd like to include a function in my query that will return their Age in years based on these three columns.



I found this function on the internets, but I'm not sure how to build a DATETIME object using the three int date columns to pass to the function. If you could help me there it'd be most appriciated.


Create FUNCTION dbo.GetAge (@DOB datetime, @Today Datetime) RETURNS Int
AS
Begin
Declare @Age As Int
Set @Age = Year(@Today) - Year(@DOB)
If Month(@Today) < Month(@DOB)
Set @Age = @Age -1
If Month(@Today) = Month(@DOB) and Day(@Today) < Day(@DOB)
Set @Age = @Age - 1
Return @AGE
End

Usage (how do i pass the three columns into this function??)

SELECT Last_Name, First_Name, ssn, dob
FROM Employee_Data e (nolock)
WHERE Cust_Id = 'Customer1'
and dbo.GetAge(e.Date_Of_Birth, getdate()) >= 21

View 3 Replies View Related

Output Several Columns Based On Rows

Jun 9, 2008

I'll show my schema first, then I'll explain what I'm doing:

--------------------------------------------------
Events
--------------------------------------------------
ID | E_Title
--------------------------------------------------


--------------------------------------------------
EventOptionGroups
--------------------------------------------------
ID | EOG_EventID | EOG_OptionGroupID
--------------------------------------------------


--------------------------------------------------
OptionGroups
--------------------------------------------------
ID | OG_Title
--------------------------------------------------


--------------------------------------------------
Options
--------------------------------------------------
ID | O_OptionGroupID | O_Description
--------------------------------------------------


--------------------------------------------------
EventRegistration
--------------------------------------------------
ID | ER_EventID | ER_Name
--------------------------------------------------


--------------------------------------------------
RegistrantOptions
--------------------------------------------------
ID | RO_EventRegistrationID | RO_OptionGroupID | RO_Selection
--------------------------------------------------



There are several events. Each event has several different sessions (stored in EventOptionGroups), and each session has a certain number of options (stored in Options).

A user can sign up for an event, and their information is stored in EventRegistration. They can choose an option for each session in the event. For each option they choose, a new row is added to RegistrantOptions.

For each row in EventRegistration, I want to output the user's information, and then the option they chose for each session in the event. Like this:

----------------------------------------------------------------------
E_Title | ER_Name | OG_Title1 | OG_Title2 | OG_Title3
----------------------------------------------------------------------
Event | Bob | O_Description1 | O_Description2 | O_Description3

So in that example, that event had 3 sessions.

Right now, I can only output E_Title and ER_Name, I don't know how to output the session information

View 2 Replies View Related

Multiply Of Columns Based On New Group

Dec 19, 2013

Product IdIsPrimaryQuantity
P0011
P001.102
P001.204
P001.305
P0021
P002.106
P002.207
P002.309
P002.4010
P002.5011

Need the query for result each group shows multiplied value of group quantity and last row of the group is shown with NULL

Product IdSubProductQuantity
P001 40
P001 P001.3NULL
P002 41580
P002 P002.5NULL

This is same as [URL] ....

View 5 Replies View Related

Sum Columns Based On A Single Column Value

Sep 10, 2014

I’m trying to figure out a way to sum columns for similar IDs, based on the contents of a single field. For example, if I’m calculating attendance percentages for students, and codes P and T count as Present, and codes A and E count as Absent, I would want to total Present and Absent codes separately, in their own columns. I would then like to use those totals to calculate percentage, but I can do that. It’s the SUM based on column value (by ID) that is giving issue.

If I have the following view:

IDLNFNCDTotal
123456MearsBenP12
123456MearsBenA2
123456MearsBenT6
234567NortonSusanP15
234567NortonSusanA2
234567NortonSusanT2
234567NortonSusanE1

I would like something like this:

IDLNFNPresentAbsentPercentage
123456MearsBen18290.0
234567NortonSusan17385.0

I’ve been playing around with nested queries, but nothing’s working. This is a glimpse of the mess that I’ve created trying to sort this out. Many errors.

I just noticed that I used a simpler example than the SQL I included, so I modified it a bit. There are additional fields that I'll need to include, but I want to get the logic working correctly. From there, I can handle the rest. So here's a more appropriate code example showing the direction I'm trying to go with this.

SELECT ID, [Last Name], [First Name], CD, Present, Absent, CAST(LEFT(Present / (Absent + Present) * 100, 5) AS varchar) + '%' AS Percentage
FROM (SELECT ID, CD, TotalAHD, CAST
((SELECT SUM(TotalAHD) AS Expr1
FROM SumAHDforAttndPercentages AS p

[Code] ...

View 2 Replies View Related

SQL Count Records Based On 2 Columns

Oct 15, 2007

Newbie alrt...

I am trying to create an asp page that will update an Access 2000 database. I need to update records if the user exists and create a new record if the user does not exist. Most of the variables are pulled from a separate "post" form.

I am using 2 pieces of info to find duplicates, as employee numbers can be assigned to multiple employees. Right now I have the page check for a duplicate employee id number then check for a duplicate last name. Unfortunately it is running each check separately, so if the last name is duplicated anywhere, it is sending a duplicated value.


here is the chunk of code in question... all RF_variables are request.form variables


cnt="SELECT COUNT(emp_id) AS Xnum FROM " & RF_course
cnt=cnt & " WHERE emp_id='" & RF_emp_id & "'"
set again=conn.Execute(cnt)
dup=again("Xnum")


if dup>=1 then
cnt="SELECT COUNT(lname) AS Xnum FROM " & RF_course
cnt=cnt & " WHERE lname='" & RF_lname & "'"
set again=conn.Execute(cnt)
dupl=again("Xnum")

if dupl=1 then
upd="UPDATE " & RF_course & " SET "
upd=upd & "section" & RF_section & "='" & RF_score & "'"
upd=upd & " WHERE emp_id='" & RF_emp_id & "'"
upd=upd & " AND lname='" & RF_lname & "'"
on error resume next
conn.Execute upd
else
ins="INSERT INTO " & RF_course
ins=ins & " (lname,fname,emp_id,cname,"
ins=ins & "section" & RF_section & ")"
ins=ins & " VALUES "
ins=ins & "('" & RF_lname & "',"
ins=ins & "'" & RF_fname & "',"
ins=ins & "'" & RF_emp_id & "',"
ins=ins & "'" & RF_cname & "',"
ins=ins & "'" & RF_score & "')"
on error resume next
conn.Execute ins
end if
else
ins="INSERT INTO " & RF_course
ins=ins & " (lname,fname,emp_id,cname,"
ins=ins & "section" & RF_section & ")"
ins=ins & " VALUES "
ins=ins & "('" & RF_lname & "',"
ins=ins & "'" & RF_fname & "',"
ins=ins & "'" & RF_emp_id & "',"
ins=ins & "'" & RF_cname & "',"
ins=ins & "'" & RF_score & "')"
on error resume next
conn.Execute ins
end if




Hopefully this is understandable.
If anyone can offer any help I would greatly appreciate it.

Thanks

View 1 Replies View Related

Why Can't I Use Columns Based On Case Down In My Where Clause

Sep 13, 2007



I am writing a fairly simple sql, and I would like to write something like




Code Snippet
select

firstname as firstname,
case

when firstname = 'Peter' then 'yes'
else

'no'
end as whatever

from

MyTable
where

whatever = 'yes'



And this should then select out the rows where column number 2 is 'yes'.

It doesn't work, and I have to copy the firstname = 'Peter' into the where clause.

But why?


View 4 Replies View Related

Selecting The Rows Based Off Of Unique Columns

Mar 18, 2007

Hi there, im still learning SQL so thanks in advance.I have a table with columns of customer's information, [customerID], [customerFirst], [customerLast], , [program] ... other columns ...  There will be entries where there can be duplicate customerFirst and customerLast names.  I would like to just return a single entry of the duplicate names and all associated row information.  IE: [customerID], [customerFirst], [customerLast],            [ email],             [program]         01               Bill                 Smith             bill.smith@hotmail.com    ymca        02               Bill                 Smith             bill.smith@hotmail.com    Sports        03               jon                   doe                 jon.doe@hotmail.com    AAA        04               jon                   doe                 jon.doe@hotmail.com    Ebay          05               Paul                 Sprite             paul.sprite@hotmail.com    Rec Desired Returned result:        01               Bill                 Smith             bill.smith@hotmail.com    ymca        03               jon                   doe                 jon.doe@hotmail.com    AAA
         05               Paul                 Sprite             paul.sprite@hotmail.com    Rec So in my code i have this:dAdapter = new SqlDataAdapter("SELECT * FROM [Poc_" + suffix + "] WHERE (SELECT DISTINCT [CustomerLastName], [CustomerFirstName], [CustomerEmail] FROM [Poc_" + suffix + "])", cnStr);         dAdapter.Fill(pocDS, "Data Set");        However this is throwing up an error when i build the app:  An expression of non-boolean type specified in a context where a condition is expected, near ')'.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException:
An expression of non-boolean type specified in a context where a
condition is expected, near ')'.

Source Error:




Line 52: //dAdapter = new SqlDataAdapter("SELECT DISTINCT * FROM [Poc_" + suffix + "] ORDER BY [CustomerLastName]", cnStr); Line 53: dAdapter = new SqlDataAdapter("SELECT * FROM [Poc_" + suffix + "] WHERE (SELECT DISTINCT [CustomerLastName], [CustomerFirstName], [CustomerEmail] FROM [Poc_" + suffix + "])", cnStr); Line 54: dAdapter.Fill(pocDS, "Data Set");Line 55: Line 56: //Dataset for name comparison  1: Can someone explain to me why this error is happening?2: Can soemone confirm that my intentions are correct with my code?3: If I'm completely off, can someone steer me in the right direction?Thanks alot!-Terry  

View 12 Replies View Related

T-SQL (SS2K8) :: How To Repeat Columns Based On Rows

Mar 6, 2014

I have two columns which needs to repeat based on ID and number of distinct rows in that ID.

ID Date Created
1 1/1/2012 Sudheer
1 1/2/2013 Sudheer
1 3/3/2013 Sudheer
2 1/2/2014 Veera
2 2/5/2015 Veera

Results

ID Date Created Date Created Date Created
1 1/1/2012 Sudh 1/2/2013 Sudh 3/3/2013 Sudh
2 1/2/2014 Veera 2/5/2015 Veera

View 3 Replies View Related







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