Showing posts with label selection. Show all posts
Showing posts with label selection. Show all posts

Sunday, March 25, 2012

Distinct Selection in SELECT

Hi all, How can I achieve this?
select col1,distinct(col2),col3,col4 from table1
TIAI have no idea what you are trying to achieve.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Vai2000" <nospam@.microsoft.com> wrote in message
news:#fgDiYlLFHA.2380@.TK2MSFTNGP10.phx.gbl...
> Hi all, How can I achieve this?
> select col1,distinct(col2),col3,col4 from table1
>
> TIA
>|||--Record present
Col1 Col2 Col3
mark 1qa 5/5/2003
mohan 2dc 1/1/2004
jerry cvse 12/31/2002
john cvse 12/31/2002
SELECT Col1,Distinct(Col2),COl3 From Table1
-- desired recordset
Col1 Col2 Col3
mark 1qa 5/5/2003
mohan 2dc 1/1/2004
jerry cvse 12/31/2002
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:egU%23UalLFHA.3868@.TK2MSFTNGP10.phx.gbl...
> I have no idea what you are trying to achieve.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
>
>
> "Vai2000" <nospam@.microsoft.com> wrote in message
> news:#fgDiYlLFHA.2380@.TK2MSFTNGP10.phx.gbl...
>|||Can you explain why jerry and not john? And if it were like this:
mark 1qa 20030505
melody 1qa 20020608
jerry cvse 20021231
john cvse 20030104
What would the output be then?
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Vai2000" <nospam@.microsoft.com> wrote in message
news:OadtVhlLFHA.2384@.tk2msftngp13.phx.gbl...
> --Record present
> Col1 Col2 Col3
> mark 1qa 5/5/2003
> mohan 2dc 1/1/2004
> jerry cvse 12/31/2002
> john cvse 12/31/2002
> SELECT Col1,Distinct(Col2),COl3 From Table1
> -- desired recordset
> Col1 Col2 Col3
> mark 1qa 5/5/2003
> mohan 2dc 1/1/2004
> jerry cvse 12/31/2002
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:egU%23UalLFHA.3868@.TK2MSFTNGP10.phx.gbl...
>|||I guess sql does a max like top..or something..I am not sure
though that's what I am trying to achieve I want distinct on col2 yet want
to select the other cols too...how can I accomplish it?
TIA
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uIhTtllLFHA.700@.TK2MSFTNGP10.phx.gbl...
> Can you explain why jerry and not john? And if it were like this:
> mark 1qa 20030505
> melody 1qa 20020608
> jerry cvse 20021231
> john cvse 20030104
> What would the output be then?
> --
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
>
> "Vai2000" <nospam@.microsoft.com> wrote in message
> news:OadtVhlLFHA.2384@.tk2msftngp13.phx.gbl...
>|||> I guess sql does a max like top..or something..I am not sure
> though that's what I am trying to achieve I want distinct on col2 yet
want
> to select the other cols too...how can I accomplish it?
You still haven't defined what you want to accomplish. You want one row for
every col2. However, if there are multiple different values for col1 and
col3, you need to define how SQL Server will determine which ones to
include.
If you do not care, say so. "ANY col1 / col3 will do." Maybe one of these
is what your after, though I question the usefulness of the extra columns if
this is the case:
SELECT MAX(Col1), Col2, MAX(col3)
FROM Table1
GROUP BY Col2
(Notice that Col1 will not necessarily come from the same row as Col3, which
is why I asked about the date AND the name that you wanted returned.)
If you do care, say so. Provide REAL specs (not typing out your data in
tabular format) as suggested in http://www.aspfaq.com/5006 (please read in
full, including the link to generate insert statements) and we can provide a
real solution.
A|||great! works for me
Thanks
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uhGB69lLFHA.3788@.tk2msftngp13.phx.gbl...
> want
> You still haven't defined what you want to accomplish. You want one row
for
> every col2. However, if there are multiple different values for col1 and
> col3, you need to define how SQL Server will determine which ones to
> include.
> If you do not care, say so. "ANY col1 / col3 will do." Maybe one of
these
> is what your after, though I question the usefulness of the extra columns
if
> this is the case:
> SELECT MAX(Col1), Col2, MAX(col3)
> FROM Table1
> GROUP BY Col2
> (Notice that Col1 will not necessarily come from the same row as Col3,
which
> is why I asked about the date AND the name that you wanted returned.)
> If you do care, say so. Provide REAL specs (not typing out your data in
> tabular format) as suggested in http://www.aspfaq.com/5006 (please read in
> full, including the link to generate insert statements) and we can provide
a
> real solution.
> A
>sql

Sunday, February 19, 2012

display parameter value on Report Builder generated report

hi all,
is it possible to display the parameter value on the report for
parameters which contain multiple selection ?
i can display the parameter value if it has only 1 value. how can i
display the values if there are more than 1 ?
Thanks!Yes can be done. use
e.g in your text box
=Join(Parameters!empno.Value, ",")
Amarnath
"minority" wrote:
> hi all,
> is it possible to display the parameter value on the report for
> parameters which contain multiple selection ?
> i can display the parameter value if it has only 1 value. how can i
> display the values if there are more than 1 ?
> Thanks!
>|||thanks Amarnath.
previously, i tried Parameters!empno.value because i only filter by 1
value but will have error. so i didn't think that the Join function
will work.
thanks.

Friday, February 17, 2012

display multi value parameters in textbox

Hello,

I have the following problem.

i have a report where you need to fill in a few parameters

start date, end date and subject selection.

the subject selection is a multivalue paramter (select all, param1, param2, param3)

the multivalue parameter is based on another dataset with paramid as value field and paramdescription as value label.

in my report i want to display something like this :

from startdate to enddate

summary for campaign(s) : selected parameters.

in the selected parameters is can display a =join(Parameter!campaig.value) but this only returns the 32bit guid.

instead i would like it to display the parameterdescription label.

anybody has some ideas ?

greetings

vince

Hi Vince,

I think using the expression =Join(Parameters!campaign.Label) should give you the desired result.

-Aayush