Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:10:01+00:00 2026-05-11T19:10:01+00:00

How can i join these two queries (Query1-Query2) Query1: declare @date1 datetime,@date2 datetime ,

  • 0

How can i join these two queries (Query1-Query2)

Query1:


declare @date1 datetime,@date2 datetime , @COUNT INT , @countgap int
seLECT @date1='2009-05-11' , @date2 = '2009-05-12'
seLECT @countgap = 30 , @COUNT = 0 

select @date1 TARIH , @COUNT SIRA 
INTO #TMP
WHILE @date1 < @date2 
BEGIN 
    SELECT  @date1 = DATEadd(minute,@countgap,@date1) , @COUNT = @COUNT +1
    INSERT INTO #TMP
    select @date1 TARIH , @COUNT SIRA 
END
SELECT TARIH , SIRA , ( 0) VISITINGCOUNT 
FROM #TMP
ORDER BY SIRA



Query2 :


select count(page) as TARIH,   
    (datepart(hour,Date)*60+datepart(minute,Date))/@countgap  as SIRA 
    from scr_SecuristLog  
    where Date between @date1  and  @date2 
    GROUP BY (datepart(hour,Date)*60+datepart(minute,Date))/@countgap

Look please ‘SIRA’. This Column equals in two datatable.
Run Query1 look result please. i need inner join two table

Query1 Result


2009-05-11 00:00:00.000 0   0
.
.
.
.
.
2009-05-11 07:00:00.000 14 0
2009-05-11 07:30:00.000 15 0
2009-05-11 08:00:00.000 16 0
2009-05-11 08:30:00.000 17 0
2009-05-11 09:00:00.000 18 0
2009-05-11 09:30:00.000 19 0
2009-05-11 10:00:00.000 20 0
2009-05-11 10:30:00.000 21 0
2009-05-11 11:00:00.000 22 0
2009-05-11 11:30:00.000 23 0
2009-05-11 12:00:00.000 24 0
2009-05-11 12:30:00.000 25 0
2009-05-11 13:00:00.000 26 0
2009-05-11 13:30:00.000 27 0
2009-05-11 14:00:00.000 28 0
2009-05-11 14:30:00.000 29 0
2009-05-11 15:00:00.000 30 0
2009-05-11 15:30:00.000 31 0
2009-05-11 16:00:00.000 32 0
2009-05-11 16:30:00.000 33 0
2009-05-11 17:00:00.000 34 0
2009-05-11 17:30:00.000 35 0
2009-05-11 18:00:00.000 36 0
.
.
.

Query2 Result


3   23
9   29
10  32
3   21
18  33

i need Result


2009-05-11 00:00:00.000 0   0
....
2009-05-11 07:00:00.000 14 0
2009-05-11 07:30:00.000 15 0
2009-05-11 08:00:00.000 16 0
2009-05-11 08:30:00.000 17 0
2009-05-11 09:00:00.000 18 33
2009-05-11 09:30:00.000 19 0
2009-05-11 10:00:00.000 20 0
2009-05-11 10:30:00.000 21 0
2009-05-11 11:00:00.000 22 0
2009-05-11 11:30:00.000 23 3
2009-05-11 12:00:00.000 24 0
2009-05-11 12:30:00.000 25 0
2009-05-11 13:00:00.000 26 0
2009-05-11 13:30:00.000 27 0
2009-05-11 14:00:00.000 28 0
2009-05-11 14:30:00.000 29 9
2009-05-11 15:00:00.000 30 0
2009-05-11 15:30:00.000 31 0
2009-05-11 16:00:00.000 32 10
2009-05-11 16:30:00.000 33 0
2009-05-11 17:00:00.000 34 0
2009-05-11 17:30:00.000 35 0
2009-05-11 18:00:00.000 36 0
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:10:01+00:00Added an answer on May 11, 2026 at 7:10 pm

    A bit tricky, as the field names doesn’t match between the tables…

    select t1.TARIH, t1.SIRA, VISITINGCOUNT = isnull(t2.SIRA, 0)
    from #TMP t1
    left join ( --paste query 2 here-- ) t2 on t2.TARIH = t1.SIRA
    order by t1.SIRA
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's no magic method allowing you to create a trigger… May 12, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer I believe InvokeRequired doesn't return appropriate values until the windows… May 12, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer A better way to add a image to a UINavigationBar… May 12, 2026 at 7:13 pm

Related Questions

I've got these two queries: SELECT SELECT NamesRecord.NameID, NamesRecord.FulfillmentAddressID NameFulfillmentAddressID, ContractRecord.FulfillmentAddressID, ContractRecord.BillingAddressId FROM Magnet.dbo.ContractRecord
I have two tables: Application applicationid (int) applicationname (varchar) isavailable (bit) and Holidays applicationid
I have two database tables with the following structure: actions: action_id int(11) primary key
A C# program I am working on will need to export data to one

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.