|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 4:05 AM
Points: 10,
Visits: 57
|
|
Hi to all I have a Query which is fix like
SELECT StudentId,EnrolmentId,SessionId,SchoolId, Name, ClassGroupId, ClassId, ClassName FROM ViewStudentTable WHERE IsBlock = 0 and sessionid=11 and schoolid=1 and classid=2
I am searching student under session 11 schoolid 1 and classid 2
Output is fine
But now People searching student under session 11 and in schoolid=1
I don't want to change query i wants that output should come with the same query
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 7:07 AM
Points: 24,
Visits: 100
|
|
Once you prefer different outputs, obviously you need to change the filtering. But, i don't know what is the problem of changing the query..
Regards, Karthik. SQL Developer.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, January 15, 2013 11:11 AM
Points: 1,945,
Visits: 2,782
|
|
Where is the DDL?
You have several classic errors. Read the ISO-11179 rules for data element names. We do not use “view” or “table” is a table name; you name it for what is s by its nature, not by its implementation. SQL does not use bit flags; that was Assembly Language in the 1950's.
Here is a guess, made without any help, as to a corrected DDL:
SELECT student_id, enrollment_id, session_id, school_id, school_name, class_group, class_id, class_name FROM Student_Enrollment WHERE session_id = 11 AND class_status <> 'blocked' AND school_id = 1 AND class_id = 2;
[quote I am searching student under (session_id = 11 AND school_id = 1 AND class_id = 2). [/quote]
No, there was no search condition with session_id in it. I had to add it.
But now People searching student with (session = 11 AND school_id = 1). I do not want to change query. but I want different output
That makes no sense, even after I fixed the English. Write a new query; it is easy.
Books in Celko Series for Morgan-Kaufmann Publishing Analytics and OLAP in SQL Data and Databases: Concepts in Practice Data, Measurements and Standards in SQL SQL for Smarties SQL Programming Style SQL Puzzles and Answers Thinking in Sets Trees and Hierarchies in SQL
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
|
|
goldyabk1 (9/8/2012) Hi to all I have a Query which is fix like
SELECT StudentId,EnrolmentId,SessionId,SchoolId, Name, ClassGroupId, ClassId, ClassName FROM ViewStudentTable WHERE IsBlock = 0 and sessionid=11 and schoolid=1 and classid=2
I am searching student under session 11 schoolid 1 and classid 2
Output is fine
But now People searching student under session 11 and in schoolid=1
I don't want to change query i wants that output should come with the same query Create a stored procedure that contains the parameters you want to search for as variables.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, February 14, 2013 12:43 AM
Points: 26,
Visits: 92
|
|
| If you use stored procedure still you need to change the query. So, it is better to change the query directly. without changing the query you can't change the output.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 4:05 AM
Points: 10,
Visits: 57
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 4:05 AM
Points: 10,
Visits: 57
|
|
|
|
|