Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Selection of Records - date data

$
0
0

SELECT show_name, show_address FROM show -----------------------------------------------

show_name show_addressDubbo 23 Wingewarra St, Dubbo Young 13 Cherry Lane, YoungCastle Hill Showground Rd, Castle Hill Royal Easter PO Box 13, GPO Sydney Dubbo 17 Fitzroy St, Dubbo

Hi I'm trying to select Dubbo at 'Wingewarra St' and Castel Hill and list the number of days between them

Dubbo at 'Wingewarra St' was held on 05/ July / 1995 and Castle Hill was held on 04/ May/ 1996 and the result should be 304 days

and here is the show table:

SELECT *

FROM show --------------------------------------------------------- show_name show_held show_address Dubbo 1995-07-05 23 Wingewarra St, Dubbo Young 1995-09-13 13 Cherry Lane, Young Castle Hill 1996-05-04 Showground Rd, Castle Hill Royal Easter 1996-04-21 PO Box 13, GPO Sydney Dubbo 1996-07-01 17 Fitzroy St, Dubbo


and Here is the code that I wrote:

SELECT		DATENAME (DAY, show_held.CastleHill) - DATENAME (DAY, show_held.Dubbo) AS number_of_days_between_show
FROM		show
WHERE		show.show_name = 'Dubbo' AND show.show_address LIKE 'Wingewarra St'

-----------------------------------------------------
Msg 4104, Level 16, State 1, Line 24
The multi-part identifier "show_held.CastleHill" could not be bound.
Msg 4104, Level 16, State 1, Line 24
The multi-part identifier "show_held.Dubbo" could not be bound.

I have no idea how to only select the day for Castle Hill and subtract the day of Dubbo that was held at Wingewarra St

Please help thank you



Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>