Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Get distinct combine non distinct

Author  Topic 

infodemers
Posting Yak Master

183 Posts

Posted - 2013-06-18 : 14:29:28
Hi ,

I wish to create a table that include a distinct list of Office from a table and add to each of them, a row with a value between 0800 to 2300. sor for every single office , I would have 16 records(rows).

Office | Hour
_____________
ABCD 0800
ABCD 0900
. .
. .
ABCD 2300
KLMN 0800
KLMN 0900 etc...

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-06-18 : 14:45:18
One way is to create a table (temp or permanent or table var or derived or cte) with your 16 rows. Then CROSS JOIN that in a select statement to your Office table. That would result in 16 rows for every office.

Be One with the Optimizer
TG
Go to Top of Page

infodemers
Posting Yak Master

183 Posts

Posted - 2013-06-18 : 16:10:25
I thank you very much, that did the trick using temp table! :-)
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-06-18 : 16:34:44
You're welcome! - thanks for the update.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -