how to create hour rows in oracle select statement with no data

I have a task of pulling data based on the date. If this data does not exists, I need to be able to return 24 blank records. I am doing this for a asp.net gridview. it should look like this, but the contract id I will be passing in via input parameter

hour     contract id     mw     additional mw     date_time
1           119                
2           119
3           119
4           119
4           119
bschave2Asked:
Who is Participating?
 
awking00Connect With a Mentor Commented:
See attached.
query.txt
0
 
slightwv (䄆 Netminder) Commented:
Just do an outer join on the following as an inline view.

This generates a list form 1 to 24:
select level from dual connect by level<=24;

0
 
bschave2Author Commented:
this is what I am trying to do. I would like to get three products side by side so that I can create a gridview to edit the data.
option-availability.jpg
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
slightwv (䄆 Netminder) Commented:
>>this is what I am trying to do.

and?  Does the query posted in http:#a35375597 using the select I posted in http:#a35369643 not return the correct rows?

Anyway:  Can't you just build the gridview with 24 rows?
0
 
bschave2Author Commented:
each row is an hour.
0
 
slightwv (䄆 Netminder) Commented:
Again, and?  I got that part.

The query provided by awking00 should generate 24 rows.  Does it not do that?
0
 
bschave2Author Commented:
my question was based on if there was no data and so it doesn't work unless you have data.
0
 
bschave2Author Commented:
nevermind. I just replaced the t.date_time with sysdate. thanks for the help.
0
 
slightwv (䄆 Netminder) Commented:
Might I ask why you didn't split points?  

The accepted answer uses the join and SQL mentioned in my post.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.