Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Obtain rows from a complex sql query

$
0
0

Hi to all, please somebody who can help me, my scenario is as next:

One table like next

Reservation (table)

  • Boat (string)
  • reservation (date)
  • class (string)
  • room1_cod (int)
  • room1 (int)
  • room2_cod (int)
  • room2 (int)
  • room3_cod (int)
  • room3 (int)

In room(x)_cod , I am saving a client code, in the room(x) , I am saving the price of the room for that client.

example:

LUSITANIA, 2014-3-1, MEDIUM, 0, 0, 145, 345, 0, 0    = client 145 ocupied room 2 paying $345

LUSITANIA, 2014-2-1, MEDIUM, 145, 345, 0, 0, 0, 0    = client 145 ocupied room 1 paying $345

LUSITANIA, 2014-1-1, MEDIUM, 0, 0, 0, 0, 145, 345    = client 145 ocupied room 3 paying $345

how would like to make an sql query for filter :

(Boat, reservation, class... with a reservation start date and finish date and with an specific "client code" find and filter this code into room1_cod , room2_cod and room3_cod .... and maybe do a temporarly table with rows containing (Boat, Reservation, Class, "client_code" , "client_pay" )

Resulting LIKE:

LUSITANIA, 2014-3-1, MEDIUM, 145, 345

LUSITANIA, 2014-2-1, MEDIUM, 145, 345

LUSITANIA, 2014-1-1, MEDIUM, 145, 345

Please I need your guidance. TKS



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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