Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have an query in which i want to show records in horizntal rows for eg.

SQL
select count(*) from registration where joiningdate between '01-sep-2011' and '10-sep-2011'  
union   
select  count(*) from registration where joiningdate between '01-sep-2011' and '10-sep-2011' and product_receipt is null
Posted
Updated 22-Dec-11 0:13am
v2
Comments
Karthik Harve 22-Dec-11 6:13am    
[Edit] pre tags added.
Slacker007 22-Dec-11 6:20am    
What is your question, exactly?
puneetisonfire89 22-Dec-11 6:28am    
sir i want to show details in horizontal way.. not in Vertical
Slacker007 22-Dec-11 6:32am    
First, don't call me sir :) I work for a living. Second, your question appears to be very bleak to me. I think you need to add more information as to what you exactly want to do besides just "wanting" horizontal versus vertical.
thatraja 22-Dec-11 6:26am    
Horizontal View? what? Not clear

Typically formatting shouldn't be done with SQL. The purpose of SQL is to fetch and manipulate data, not to format it. Formatting should be done on the client side, in the application calling the database.
 
Share this answer
 
Comments
Amir Mahfoozi 22-Dec-11 11:54am    
+5 I agree with you.
Wendelius 22-Dec-11 11:56am    
Thank you Amir :)
try this,hope it will help you.

SQL
with a as
 (
 select row_number() over(order by (select 1)) as rownumber,id,view1 from heview --here ur table name and column names ie id.. 
 ),
 b as
 (
   select row_number() over(order by (select 1)) as rownumber,id,view1 from  a where rownumber%2 <>0
 ),
 c as
 (
   select row_number() over(order by (select 1)) as rownumber,id,view1 from  a where rownumber%2 =0
 )
select c.id,c.view1,b.id,b.view1 from b,c where b.rownumber=c.rownumber
 
Share this answer
 
v2
Maybe you can use case statment

select count(*) Total,
Sum( Case When product_receipt Is Null then 1
Else 0
End) Total_Receipt_Null
From registration
Where joiningdate
between '01-sep-2011' and '10-sep-2011'
 
Share this answer
 
it gd bt row_number() is not works in sql 2000
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900