How to get multiresult with multicondition in Sql Server -
i need solve this.
hopefully can giving me advices.
for sample, i've got data :
proclib.march 1 first 10 rows flight date depart orig dest miles boarded capacity ----------------------------------------------------------------- 114 01mar94 7:10 lga lax 2475 172 210 202 01mar94 10:43 lga ord 740 151 210 219 01mar94 9:31 lga lon 3442 198 250 622 01mar94 12:19 lga fra 3857 207 250 132 01mar94 15:35 lga yyz 366 115 178 271 01mar94 13:17 lga par 3635 138 250 302 01mar94 20:22 lga 229 105 180 114 02mar94 7:10 lga lax 2475 119 210 202 02mar94 10:43 lga ord 740 120 210 219 02mar94 9:31 lga lon 3442 147 250
and have condition ('lax,ord'), 'lax','lon','yyz',('par,lon,fra'),'fra' ...and else
what should data show report condition in sql?
parameter made is
dest @dest -> (from table condition(('lax, ord'), 'lax','lon',('par,lon,fra'),'fra',..etc)) +'%' , date @date + '%' , depart @depart + '%'
if choose 'lax'
@dest
, 'lax'
show
if choose 'lax,ord'
@dest
, 'lax'
, 'ord'
show
please need help, advice , suggestion this.
thanks
if @dest
value 'lax,ord', 1 query solve solution is
select * proclib.march dest in ('lax','ord')
to parameterise that, need become table.
dest ==== lax ord
and query becomes
select * proclib.march dest in (select dest @desttable)
if want pass @dest
string parameter, need split somehow table. search sql split function give number of options.
if query encapsulated in stored procedure, better method pass values table valued parameter. see http://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/
Comments
Post a Comment